pip icon indicating copy to clipboard operation
pip copied to clipboard

Confirm before installing requirements globally

Open almahdi404 opened this issue 2 years ago • 4 comments

What's the problem this feature will solve?

This will save you from mistakenly installing your project's requirements globally

Describe the solution you'd like

Check if virtualenv is activated. If not then ask for confirmation

Installing requirements

$ pip install -r requirements.txt
Installing globally, Proceed (Y/n)?                        # If virtualenv not activated

to skip check

$ pip install -r -y requirements.txt

Alternative Solutions

It has to be added to pip itself.

Additional context

https://pip.pypa.io/en/stable/cli/pip_uninstall/#cmdoption-y

Code of Conduct

almahdi404 avatar Aug 03 '22 19:08 almahdi404

You can use the --require-virtualenv option (which you can set via an environment variable or in your config file) to get a very similar effect.

pfmoore avatar Aug 03 '22 19:08 pfmoore

It is very good. Wouldn't it be better if it was the default behaviour?

I think no body would want to install requirements globally

And if you want force install globally, you could use a -f flag

$ pip install -f -r requirements.txt

almahdi404 avatar Aug 04 '22 05:08 almahdi404

I think all pip maintainers want to make it the default behaviour, except a lot of people out there are going to be very angry about it.

uranusjr avatar Aug 04 '22 09:08 uranusjr

See https://github.com/pypa/pip/issues/10833 where this was discussed extensively, with the conclusion being to use a different mechanism that'll propagate more slowly to minimise churn costs for us.

pradyunsg avatar Aug 04 '22 09:08 pradyunsg