File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
src/pip/_internal/commands Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change 1+ Prevent --user installs if site.ENABLE_USER_SITE is set to False.
Original file line number Diff line number Diff line change @@ -633,6 +633,7 @@ def decide_user_install(
633633 logger .debug ("Non-user install by explicit request" )
634634 return False
635635
636+ # If we have been asked for a user install explicitly, check compatibility.
636637 if use_user_site :
637638 if prefix_path :
638639 raise CommandError (
@@ -644,6 +645,13 @@ def decide_user_install(
644645 "Can not perform a '--user' install. User site-packages "
645646 "are not visible in this virtualenv."
646647 )
648+ # Catch all remaining cases which honour the site.ENABLE_USER_SITE
649+ # value, such as a plain Python installation (e.g. no virtualenv).
650+ if not site .ENABLE_USER_SITE :
651+ raise InstallationError (
652+ "Can not perform a '--user' install. User site-packages "
653+ "are disabled for this Python."
654+ )
647655 logger .debug ("User install by explicit request" )
648656 return True
649657
You can’t perform that action at this time.
0 commit comments