-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Display warning when 'SUDO_COMMAND' in os.environ #2403
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
Conversation
870d424
to
e291c5a
Compare
Because using sudo with pip is often a mistake; often people either: - don't realize that `sudo` won't honor their activated virtualenv - are trying to manage packages in their system python, which can break systems and is often better left to the system package manager.
e291c5a
to
ee6f13e
Compare
Comments about this one? I just remembered it because one of our devs just unknowingly did |
Just ran into this again today. One of our devs had trouble upgrading because he apparently had previously done a
This would be nice to have to prevent such issues. |
As much as I'd love to see this problem fixed, I suspect that a simple warning won't cut it for a couple of reasons: 1) people ignore warnings, 2) when unsure or can't be bothered, people go with the default (which is "do nothig"). Now, clearly, a warning is better than nothing. It also could be a good first step towards a final solution, whatever that might be. For example, |
I'm going to close this. I don't think raising a warning, especially one this intrusive, is something we should do. Using pip via sudo is a perfectly valid use case. |
When is using I've done it myself on occasion on my laptop to quickly upgrade some tool I use a lot, but I've always felt dirty doing it and knew that it was risky and I should probably be using something like pipsi or something instead of risking breaking my system. I've run into a fair amount of other people borking things by accidentally doing
Certainly if |
Whenever you want to install something into the global site packages that isn't available in your package manager. In Debian Jessie with the It's a bit like making |
Well some folks, like @hynek, would say "Don’t pip-install anything into its global site-packages beyond virtualenv.". But he's already made that point and probably a lot of people aren't going to follow it all the time for one reason or another. That said, I thought of a different strategy, which is putting the warning in virtualenv instead. That might be annoying too, but it does at least have the advantage that it only come into play if someone has activated a virtualenv which was not true of this change in pip. So this would allow folks to |
Isn't that an excellent use case for Are there some cases where |
Yea, when you want to install something for the entire system. |
What if this were configurable and off by default? |
well, unlike make install, ay pip install as superuser has the potential of completely wwreck the system package manager - and since pip has zero integration wit the os level package manager i think its very fair not to warn, but to actually ask for confirmation - because a pip install is not like a make install prior to completely avoiding it i wrecked my system quit a few times with sudo pip install also its not something you immediately discover, i have seen people do that, test their stuff |
Or what we had happen several times is someone did this on a shared system. They thought they were upgrading packages for their app's virtualenv, but they had in fact messed up the system. So even if it's not the default behavior, I would love a way to turn on some kind of check for this on the system level. |
I wonder if distro folks might appreciate this. The fact that it works "reasonably well" on Debian Jessie suggests to me that it doesn't work well on other distros. We certainly had problems with this on Ubuntu and OS X systems. I wouldn't be surprised if |
Because using sudo with pip is often a mistake; often people either:
sudo
won't honor their activated virtualenvpip
to manage packages in their system python, which can breaksystems and is often better left to the system package manager.
This is a warning rather than a fatal error, so that it is less likely to break someone's workflow or tools.
This is inspired by:
source /path/to/virtualenv/bin/activate; sudo -u appuser pip install foobar
and installing cruft in the system Python.--require-virtualenv
output more info #2401 (comment)Cc: @aconrad, @sudarkoff, @sontek