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

Fix "Permission denied"/"Access refused" error when installing or updating packages (solves #9527, #9566, #9395) #10454

Closed
wants to merge 3 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/10454.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix "Permission denied" error when installing or updating packages.
14 changes: 9 additions & 5 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,6 @@ def decide_user_install(
logger.debug("Non-user install due to --prefix or --target option")
return False

# If user installs are not enabled, choose a non-user install
if not site.ENABLE_USER_SITE:
logger.debug("Non-user install because user site-packages disabled")
return False

# If we have permission for a non-user install, do that,
# otherwise do a user install.
if site_packages_writable(root=root_path, isolated=isolated_mode):
Expand All @@ -667,6 +662,15 @@ def decide_user_install(
"Defaulting to user installation because normal site-packages "
"is not writeable"
)

# Assert user installs are enabled
if not site.ENABLE_USER_SITE:
raise InstallationError(
"Can not perform user install because user site-packages "
"are disabled. Enable them or run "
"installation with privileged access."
)

return True


Expand Down