Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

pip should auto-sudo itself if root priviledges are required #290

Closed
ssbarnea opened this Issue May 28, 2011 · 7 comments

Comments

Projects
None yet
4 participants
Contributor

ssbarnea commented May 28, 2011

Instead of failing to install or uninstall stuff when it is run by a normal user, pip should try to execute itself with sudo.

This would improve pip user experience without adding security risks (sudo will ask for password if needed).

Contributor

carljm commented May 28, 2011

No, I don't think so. For one thing, I don't think I've ever encountered a Unix utility that did this (including pip's closest analogue, the package managers, which pretty much always need sudo). So this would be surprising behavior to me, and I think most users.

Secondly, the encouraged means of using pip is via virtualenv, which doesn't require sudo. 10 times out of 10 when I get permissions problems in pip, its because I forgot to activate a virtualenv, not because I forgot to use sudo. Auto-sudo is counterproductive in this case, and especially problematic if I have sudo setup to not require a password.

I'd accept a patch to make the permissions error friendlier, and mention virtualenv and sudo (on appropriate platforms) as possible fixes.

@carljm carljm closed this May 28, 2011

Contributor

ssbarnea commented May 29, 2011

Is there any way to detect from code that you forgot to specify the virtualenv or you were just interested to install to the system? If there is I may invest some time for this :)

Contributor

carljm commented May 29, 2011

You can detect from the code whether you are running inside a virtualenv, but no, you can't detect the user's intent - pip can't read minds ;)

Contributor

ssbarnea commented May 30, 2011

It seamns that I am not the only person looking for this kind of feature, check http://stackoverflow.com/questions/5363633/virtualenv-and-pip-on-a-mac-does-it-pickup-the-environment-automatically

As other similar virtual-environment solutions already provide something like this, I would like to see the opinion of the product owner regarding this.

kmike commented May 30, 2011

I have my virtualenvs at ~/envs/<env_name> and project sources at ~/src/<env_name> - how can pip know this?

Anyway, this is not pip's issue, this should be virtualenv's issue ("auto-activation of the specific virtualenv when user enters some folder"). There are shell scripts in the wild that can do this (e.g. http://hmarr.com/2010/jan/19/making-virtualenv-play-nice-with-git/ ). I personally found this behavior too magic, but that's only my opinion.

Contributor

vsajip commented May 30, 2011

@ssbarnea: Who do you mean by "the product owner"? Carl is committer on both pip and virtualenv, and he's made his view clear.

Actually I prefer that pip fails rather than prompting for a password; while it would be obvious when pip is run from the command line, what if it's run from a script? It wouldn't then be obvious which program was asking for a password, or why. If you typed in the password, you could mess up your system Python environment, when you didn't intend to.

Contributor

carljm commented May 30, 2011

Hi @ssbarnea - I'm a bit confused now whether we're talking about auto-sudo (which is not going to happen - that's why this bug is closed) or automatic virtualenv activation on entering a directory? The latter is entirely off-topic for this bug, and would be a feature request for virtualenv, not pip, as @kmike points out. If you're willing, please edit your comment on the StackOverflow question to direct people to the pip/virtualenv mailing list (http://groups.google.com/group/python-virtualenv/) rather than to this bug, if they want to discuss hypothetical new features in virtualenv.

FWIW, I don't think automatic per-directory activation really belongs in virtualenv either, it would be a better fit for a project like virtualenvwrapper. Virtualenv's scope is the virtualized python environment itself, and is mostly un-opinionated about how you organize and use your virtualenvs. Virtualenvwrapper provides a more opinionated set of shell conveniences around virtualenv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment