# Buggy code
def shell(three=None, python=False, compat=False, shell_args=None, anyway=False):
    # Prevent user from activating nested environments.
    if "PIPENV_ACTIVE" in os.environ:
        # If PIPENV_ACTIVE is set, VIRTUAL_ENV should always be set too.
        venv_name = os.environ.get("VIRTUAL_ENV", "UNKNOWN_VIRTUAL_ENVIRONMENT")

        if not anyway:
            click.echo(
                "{0} {1} {2}\nNo action taken to avoid nested environments.".format(
                    crayons.white("Shell for"),
                    crayons.green(venv_name, bold=True),
                    crayons.white("already activated.", bold=True),
                ),
                err=True,
            )

            sys.exit(1)

    # Load .env file.
    load_dot_env()

    do_shell(three=three, python=python, compat=compat, shell_args=shell_args)


# Traceback (TypeError)
kim@kimberly-whom-death-forgot:~$ pipenv shell
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/pipenv/cli.py", line 1785, in shell
load_dot_env()
File "/usr/local/lib/python3.5/dist-packages/pipenv/cli.py", line 117, in load_dot_env
denv = dotenv.find_dotenv(os.sep.join([project.project_directory, '.env']))
File "/usr/local/lib/python3.5/dist-packages/pipenv/project.py", line 62, in project_directory
return os.path.abspath(os.path.join(self.pipfile_location, os.pardir))
File "/usr/lib/python3.5/posixpath.py", line 89, in join
genericpath._check_arg_types('join', a, *p)
File "/usr/lib/python3.5/genericpath.py", line 143, in _check_arg_types
(funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'

# Fixed code
def shell(three=None, python=False, compat=False, shell_args=None, anyway=False):
    # Prevent user from activating nested environments.
    if "PIPENV_ACTIVE" in os.environ:
        # If PIPENV_ACTIVE is set, VIRTUAL_ENV should always be set too.
        venv_name = os.environ.get("VIRTUAL_ENV", "UNKNOWN_VIRTUAL_ENVIRONMENT")

        if not anyway:
            click.echo(
                "{0} {1} {2}\nNo action taken to avoid nested environments.".format(
                    crayons.white("Shell for"),
                    crayons.green(venv_name, bold=True),
                    crayons.white("already activated.", bold=True),
                ),
                err=True,
            )

            sys.exit(1)

    # Ensure that virtualenv is available.
    ensure_project(three=three, python=python, validate=False)

    # Load .env file.
    load_dot_env()

    do_shell(three=three, python=python, compat=compat, shell_args=shell_args)