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

Allow to disable warning for root user package management #10990

Merged
merged 2 commits into from
Apr 7, 2022

Conversation

potiuk
Copy link
Contributor

@potiuk potiuk commented Mar 26, 2022

This PR implements the flag that allows to disable the root
warning when using pip to install packages. While there are
differing opinions on this, it seems that the final decision is
to lean forward to implement a long and not very easily
discoverable flag to accommodate the minority of users who know
what they are doing and using root installation to - for example
build optimized Dockerfiles.

Even approval, and eventually an adoption of PEP 668 to make the
problem largely go away is still a long time to go, so as
discussed in #10556 (comment)
this PR adds a long and non-user friendly flag to handle the
situation.

Fixes: #10556

@potiuk potiuk changed the title Allows to disable warning for root user package management Allow to disable warning for root user package management Mar 26, 2022
@potiuk potiuk force-pushed the fix-root-warning branch 3 times, most recently from 1644193 to f536c1f Compare March 26, 2022 22:53
Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up! ^.^

I have a few suggestions for changes throughout this PR, mostly around being consistent with the rest of the implementation for how we handle options.

I would request you to drop the reference to the issue from the commit message, since that causes excessive spam in the original GitHub issue, with an event every time you make a force-push.

Since you'll likely be editing the commit message, as a nit-pick, it would be good for it to not reference specific URLs and to not state "this PR" (it's associated with commit, which can be used independently of a PR).

src/pip/_internal/commands/install.py Outdated Show resolved Hide resolved
src/pip/_internal/commands/install.py Outdated Show resolved Hide resolved
src/pip/_internal/commands/uninstall.py Outdated Show resolved Hide resolved
src/pip/_internal/commands/uninstall.py Outdated Show resolved Hide resolved
news/10990.feature.rst Outdated Show resolved Hide resolved
src/pip/_internal/commands/install.py Outdated Show resolved Hide resolved
src/pip/_internal/commands/install.py Outdated Show resolved Hide resolved
@pradyunsg pradyunsg added the type: feature request Request for a new feature label Mar 27, 2022
Implements the flag that allows to disable the root
warning when using `pip` to install packages. While there are
differing opinions on this, it seems that the final decision is
to lean forward to implement a long and not very easily
discoverable flag to accommodate the minority of users who know
what they are doing and using root installation to - for example
build optimized Dockerfiles.
@potiuk
Copy link
Contributor Author

potiuk commented Mar 27, 2022

I believe all comments applied. Thanks for fast review!

@potiuk
Copy link
Contributor Author

potiuk commented Mar 27, 2022

Tested it manually too:

Screenshot 2022-03-27 at 09 46 02

Screenshot 2022-03-27 at 09 51 03

Given that this option is on the install/uninstall commands, it is
implied that the warning is presented as part of an
installation/uninstallation.
@pradyunsg pradyunsg added this to the 22.1 milestone Mar 27, 2022
@uranusjr uranusjr merged commit 0ac0f84 into pypa:main Apr 7, 2022
@potiuk potiuk deleted the fix-root-warning branch April 7, 2022 09:44
@potiuk
Copy link
Contributor Author

potiuk commented Apr 7, 2022

Cool! thanks!

@ssbarnea
Copy link
Contributor

ssbarnea commented Apr 7, 2022

Does this also mean that we can define PIP_WARN_ABOUT_ROOT_USER=0 to disable it?

@uranusjr
Copy link
Member

uranusjr commented Apr 7, 2022

I think it needs to be PIP_NO_WARN_ABOUT_ROOT_USER=0 due to an optparse quirk, but yes environment variables should work

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature request Request for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an opt-out for the “running as root” warning
4 participants