Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't check against root directory #4275

Merged
merged 6 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/4273.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that Pipenv rejects to work under the root directory.
13 changes: 4 additions & 9 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down
16 changes: 4 additions & 12 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,18 +682,10 @@ def pipfile_is_empty(self):

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:
Expand Down