Skip to content

Commit a01fabd

Browse files
committed
Don't erroneously emit warning about running pip as root
Check the uid using getuid() on platforms other than Linux and Mac OS before warning about running pip as root. Before this change, pip was emitting this warning even when it was run as a non-root user.
1 parent 9f18a40 commit a01fabd

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

news/10565.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Only warn about running pip as root if it is actually being run as root

src/pip/_internal/cli/req_command.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ def warn_if_run_as_root() -> None:
173173
# checks: https://mypy.readthedocs.io/en/stable/common_issues.html
174174
if sys.platform == "win32" or sys.platform == "cygwin":
175175
return
176-
if sys.platform == "darwin" or sys.platform == "linux":
177-
if os.getuid() != 0:
178-
return
176+
177+
if os.getuid() != 0:
178+
return
179+
179180
logger.warning(
180181
"Running pip as the 'root' user can result in broken permissions and "
181182
"conflicting behaviour with the system package manager. "

0 commit comments

Comments
 (0)