diff --git a/news/4273.bugfix.rst b/news/4273.bugfix.rst new file mode 100644 index 00000000..a6140178 --- /dev/null +++ b/news/4273.bugfix.rst @@ -0,0 +1 @@ +Fix a bug that Pipenv rejects to work under the root directory. diff --git a/pipenv/core.py b/pipenv/core.py index 1938e7f5..a90afa60 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -126,8 +126,11 @@ def do_clear(): try: vistir.path.rmtree(PIPENV_CACHE_DIR, onerror=vistir.path.handle_remove_readonly) + # Other processes may be writing into this directory simultaneously. vistir.path.rmtree( - locations.USER_CACHE_DIR, onerror=vistir.path.handle_remove_readonly + locations.USER_CACHE_DIR, + ignore_errors=environments.PIPENV_IS_CI, + onerror=vistir.path.handle_remove_readonly ) except OSError as e: # Ignore FileNotFoundError. This is needed for Python 2.7. @@ -568,14 +571,6 @@ def ensure_project( system = True if not project.pipfile_exists and deploy: raise exceptions.PipfileNotFound - # Fail if working under / - if not project.name: - click.echo( - "{0}: Pipenv is not intended to work under the root directory, " - "please choose another path.".format(crayons.red("ERROR")), - err=True - ) - sys.exit(1) # Skip virtualenv creation when --system was used. if not system: ensure_virtualenv( diff --git a/pipenv/project.py b/pipenv/project.py index 16bc715d..796489f7 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -682,18 +682,10 @@ class Project(object): def create_pipfile(self, python=None): """Creates the Pipfile, filled with juicy defaults.""" - from .vendor.pip_shims.shims import ( - ConfigOptionParser, make_option_group, index_group - ) - - config_parser = ConfigOptionParser(name=self.name) - config_parser.add_option_group(make_option_group(index_group, config_parser)) - install = config_parser.option_groups[0] - indexes = ( - " ".join(install.get_option("--extra-index-url").default) - .lstrip("\n") - .split("\n") - ) + from .vendor.pip_shims.shims import InstallCommand + # Inherit the pip's index configuration of install command. + command = InstallCommand() + indexes = command.cmd_opts.get_option("--extra-index-url").default sources = [DEFAULT_SOURCE] for i, index in enumerate(indexes): if not index: