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 install path #6801

Closed
wants to merge 7 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
2 changes: 2 additions & 0 deletions news/6762.bugfix
@@ -0,0 +1,2 @@
Fail without collecting and downloading packages if user doesn't have write permissions.
* fixed linting issue in #6800
28 changes: 27 additions & 1 deletion src/pip/_internal/commands/install.py
Expand Up @@ -277,7 +277,33 @@ def __init__(self, *args, **kw):
self.parser.insert_option_group(0, cmd_opts)

def run(self, options, args):
# type: (Values, List[Any]) -> int
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