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

Use warnings module for running as root message #10792

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/10792.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Use warnings module for producing warning when run as root and outside a
virtual environment.
3 changes: 2 additions & 1 deletion src/pip/_internal/cli/req_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging
import os
import sys
import warnings
from functools import partial
from optparse import Values
from typing import Any, List, Optional, Tuple
Expand Down Expand Up @@ -177,7 +178,7 @@ def warn_if_run_as_root() -> None:
if os.getuid() != 0:
return

logger.warning(
warnings.warn(
"Running pip as the 'root' user can result in broken permissions and "
"conflicting behaviour with the system package manager. "
"It is recommended to use a virtual environment instead: "
Expand Down