# Buggy code
def cli(
    ctx,
    where=False,
    venv=False,
    rm=False,
    bare=False,
    three=False,
    python=False,
    help=False,
):
    if ctx.invoked_subcommand is None:
        # --where was passed...
        if where:
            do_where(bare=bare)
            sys.exit(0)

        # --venv was passed...
        elif venv:
            with spinner():
                loc = project.virtualenv_location

            # There is no virtualenv yet.
            if not project.virtualenv_exists:
                click.echo(
                    crayons.red("No virtualenv has been created for this project yet!"),
                    err=True,
                )
                sys.exit(1)
            else:
                click.echo(project.virtualenv_location)
                sys.exit(0)

        # --rm was passed...
        elif rm:
            with spinner():
                loc = project.virtualenv_location

            if project.virtualenv_exists:
                click.echo(
                    crayons.yellow(
                        "{0} ({1})...".format(
                            crayons.yellow("Removing virtualenv"), crayons.green(loc)
                        )
                    )
                )
                with spinner():
                    # Remove the virtualenv.
                    shutil.rmtree(project.virtualenv_location)
                sys.exit(0)
            else:
                click.echo(
                    crayons.red("No virtualenv has been created for this project yet!"),
                    err=True,
                )
                sys.exit(1)

        # --two / --three was passed...
        if python or three is not None:
            ensure_project(three=three, python=python)

        else:
            # Display help to user, if no commands were passed.
            click.echo(format_help(ctx.get_help()))


# Traceback (AttributeError)
~  pipenv install
Creating a Pipfile for this project...
Creating a virtualenv for this project...
⠋New python executable in /Users/ryan/.virtualenvs/ryan-a3k9euAf/bin/python2.7
Also creating executable in /Users/ryan/.virtualenvs/ryan-a3k9euAf/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /Users/ryan/.virtualenvs/ryan-a3k9euAf
No package provided, installing all dependencies.
Pipfile found at /Users/ryan/Pipfile. Considering this to be the project home.
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
⠸Locking [packages] dependencies...
⠴Updated Pipfile.lock!
Installing dependencies from Pipfile.lock...
⠦
⠴
To activate this project's virtualenv, run the following:
$ pipenv shell
~  rm Pipfile*
~  pipenv --rm
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 1043, in invoke
return Command.invoke(self, ctx)
File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pipenv/cli.py", line 713, in cli
loc = project.virtualenv_location
File "/usr/local/lib/python2.7/site-packages/pipenv/project.py", line 76, in virtualenv_location
c = delegator.run('pew dir "{0}"'.format(self.virtualenv_name))
File "/usr/local/lib/python2.7/site-packages/pipenv/project.py", line 57, in virtualenv_name
sanitized = re.sub(r'[ $`!*@"\\\r\n\t]', '_', self.name)[0:42]
File "/usr/local/lib/python2.7/site-packages/pipenv/project.py", line 32, in name
self._name = self.pipfile_location.split(os.sep)[-2]
AttributeError: 'NoneType' object has no attribute 'split'

# Fixed code
def cli(
    ctx,
    where=False,
    venv=False,
    rm=False,
    bare=False,
    three=False,
    python=False,
    help=False,
):
    if ctx.invoked_subcommand is None:
        # --where was passed...
        if where:
            do_where(bare=bare)
            sys.exit(0)

        if not project.pipfile_exists:
            click.echo(crayons.red("No Pipfile found."), err=True)
            sys.exit(1)

        # --venv was passed...
        elif venv:
            with spinner():
                loc = project.virtualenv_location

            # There is no virtualenv yet.
            if not project.virtualenv_exists:
                click.echo(
                    crayons.red("No virtualenv has been created for this project yet!"),
                    err=True,
                )
                sys.exit(1)
            else:
                click.echo(project.virtualenv_location)
                sys.exit(0)

        # --rm was passed...
        elif rm:
            with spinner():
                loc = project.virtualenv_location

            if project.virtualenv_exists:
                click.echo(
                    crayons.yellow(
                        "{0} ({1})...".format(
                            crayons.yellow("Removing virtualenv"), crayons.green(loc)
                        )
                    )
                )
                with spinner():
                    # Remove the virtualenv.
                    shutil.rmtree(project.virtualenv_location)
                sys.exit(0)
            else:
                click.echo(
                    crayons.red("No virtualenv has been created for this project yet!"),
                    err=True,
                )
                sys.exit(1)

        # --two / --three was passed...
        if python or three is not None:
            ensure_project(three=three, python=python)

        else:
            # Display help to user, if no commands were passed.
            click.echo(format_help(ctx.get_help()))