diff --git a/news/10565.bugfix.rst b/news/10565.bugfix.rst new file mode 100644 index 00000000000..52b70987fbf --- /dev/null +++ b/news/10565.bugfix.rst @@ -0,0 +1 @@ +Only warn about running pip as root if it is actually being run as root diff --git a/src/pip/_internal/cli/req_command.py b/src/pip/_internal/cli/req_command.py index c224bd276e2..dbd15cbce63 100644 --- a/src/pip/_internal/cli/req_command.py +++ b/src/pip/_internal/cli/req_command.py @@ -173,9 +173,10 @@ def warn_if_run_as_root() -> None: # checks: https://mypy.readthedocs.io/en/stable/common_issues.html if sys.platform == "win32" or sys.platform == "cygwin": return - if sys.platform == "darwin" or sys.platform == "linux": - if os.getuid() != 0: - return + + if os.getuid() != 0: + return + logger.warning( "Running pip as the 'root' user can result in broken permissions and " "conflicting behaviour with the system package manager. "