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

Check path permissions earlier during install #6800

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions news/6762.bugfix
@@ -0,0 +1 @@
Fail without collecting and downloading packages if user doesn't have write permissions.
25 changes: 25 additions & 0 deletions src/pip/_internal/commands/install.py
Expand Up @@ -240,6 +240,31 @@ def __init__(self, *args, **kw):
self.parser.insert_option_group(0, cmd_opts)

def run(self, options, args):
if (options.target_dir is not None and not
check_path_owner(options.target_dir)):
logger.error(
"The user that ran pip install doesn't have write access "
"to target directory '%s'",
options.target_dir,
)
return ERROR
if (options.prefix_path is not None and not
check_path_owner(options.prefix_path)):
logger.error(
"The user that ran pip install doesn't have write access "
"to target prefix directory '%s'",
options.prefix_path,
)
return ERROR
if (options.root_path is not None and not
check_path_owner(options.root_path)):
logger.error(
"The user that ran pip install doesn't have write access "
"to target root directory '%s'",
options.root_path,
)
return ERROR

cmdoptions.check_install_build_global(options)
upgrade_strategy = "to-satisfy-only"
if options.upgrade:
Expand Down