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

Ignore --user in virtual environments #7164

Closed
pradyunsg opened this issue Oct 8, 2019 · 9 comments
Closed

Ignore --user in virtual environments #7164

pradyunsg opened this issue Oct 8, 2019 · 9 comments
Labels
auto-locked Outdated issues that have been locked by automation type: feature request Request for a new feature

Comments

@pradyunsg
Copy link
Member

pradyunsg commented Oct 8, 2019

What's the problem this feature will solve?

Ensure that folks who do pip config set install.user true can continue using virtual environments without "--user isn't visible, aborting" messages. :)

Describe the solution you'd like

--user does nothing in a virtualenv that does not have system site-packages access.

Alternative Solutions

Maintain status quo. Or #7002. Or something else entirely!

Additional context

#4141 (comment) -- some past discussion.
#6984 (comment) -- a proposed way to implement this.

@takluyver
Copy link
Member

I've sketched out a related approach in #7002: default to --user if user site-packages are visible and the normal site-packages directory is not writable. This comes from the other direction, trying to remove the need to use --user or PIP_USER in the first place.

The big advantage my approach has is that it's not virtualenv specific. Pip's virtualenv detection won't notice environments made by conda or pyenv, but I think people expect similar behaviour in all of them. It's treating system Python (with read-only site-packages) as a special case rather than environments.

To frame it another way, this is the logic I think makes sense:

try:
    normal_install()
except PermissionError:
    if user_site_enabled:
        user_install()

@pradyunsg
Copy link
Member Author

Yea, I've looked at the approach outlined in #7002 and, on a quick read then and a slightly relaxed read a few minutes ago, and nothing about it immediately raises concerns to me.

@pfmoore
Copy link
Member

pfmoore commented Oct 8, 2019

I agree, I've not read #7002 in detail, but in general, I prefer an approach that makes it less necessary to need to specify --user in the first place. It fits in with my feeling that we should get the base behaviour right, rather than making the user choose explicitly and then having to deal with the interactions of all the choices users can make.

@Julian
Copy link
Contributor

Julian commented Oct 9, 2019

To throw my 0.02 in the hat... I agree with the sentiment that the default should change too but I think it'd be great if that didn't get in the way of the simplicity of this on its own.

Muscle memory means I occasionally type --user even if I'm talking to a venv's pip, and then get that funny error message.

Of course making me never need to type it would be great, which lots of us have hoped for for quite a few years now :), but making things not blow up still seems nice and self contained and maybe not take as long / be as contentious :).

@pradyunsg
Copy link
Member Author

Okay, I slept over this and I think #7002 is a good idea and we should definitely do it. I'm sure there's gonna be edge cases and all, but overall, it should be a much better approach than what I'm proposing here.

Also, if we do #7002, then our current behavior for --user in virtualenv makes a lot of sense. We can even update our error messages for that case, to tell the user to remove --user since we're defaulting to it now.

@pradyunsg
Copy link
Member Author

Basically, I agree with @takluyver that #7002 is a better approach to this overall. :)

@pradyunsg
Copy link
Member Author

Closing since #7002 has merged.

@chrahunt
Copy link
Member

@pradyunsg I think this was more to contrast the behavior updated with PR #7155, that is: if --user is indicated anywhere (CLI, environment, configuration) while we are in a virtual environment which does not have system site packages enabled (the default IIRC) then pip aborts.

That said, the reason that this would happen for users is because they would put user = true in config to avoid accidental global installation, so maybe the general best-practice advice should be to upgrade to 19.4 (20.0?) when it is released and then just execute pip install ... which should do the right thing?

@pradyunsg
Copy link
Member Author

so maybe the general best-practice advice should be to upgrade to 19.4 (20.0?)

Yep.

I feel this doesn't as much sense if we have saner defaults that work better in this case. Explicit opt-ins shouldn't be needed then, which should make things easier to manage. : )

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Nov 22, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

5 participants