Repository: pypa/pip

Issue:
Better document --root-user-action
### Description

Hello everyone, I'm using Vagrant/Docker for some long-term testing and would like to silence pip's warning about running as root so I can deal with other more relevant warnings.

I found this PR #10990 from April 7th, 2022 but I haven't managed to able to run pip as root without the warning.

I'm using Alpine on Docker/Vagrant and have a bunch of other packages but the python/pip that are installed;  

```
-  python3-dev 
-  py3-pip 
-  py3-virtualenv 
```

I've tried 
```
python3 -m pip install --upgrade pip && \ 
PIP_NO_WARN_ABOUT_ROOT_USER=0 pip install sqlmap
#and
env PIP_NO_WARN_ABOUT_ROOT_USER=0 pip install sqlmap
```
Can anybody help?

### Expected behavior

No longer have the root warning output

### pip version

pip-22.1.2

### Python version

3.10.4

### OS

Alpine

### How to Reproduce

docker run -it alpine:latest /bin/sh

apk update
apk add py3-pip

python3 -m pip install --upgrade pip

pip -V
pip 22.1.2 from /usr/lib/python3.10/site-packages/pip (python 3.10)

PIP_NO_WARN_ABOUT_ROOT_USER=0 pip install sqlmap

### Output

```sh-session
WARNING: 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: https://pip.pypa.io/warnings/venv
```


### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).


Discussion:
The initial implementation has been superseeded by: https://github.com/pypa/pip/pull/11035. You can disable it by adding ``--root-user-action ignore`` but you have to exactly know what you want to do. The warning has its reasoning - but running pip as root might have sense in docker, but not always.

You can read more about context in  https://github.com/pypa/pip/issues/10556
Another option is `PIP_ROOT_USER_ACTION=ignore` I guess 
Let’s document this better.
Shall I prpose a doc PR @uranusjr ? 
Wonderful, thank you anyone. :)
A PR would be awesome
Will do.
Submitted a proposal.

Resolving patch:
diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py
--- a/src/pip/_internal/cli/cmdoptions.py
+++ b/src/pip/_internal/cli/cmdoptions.py
@@ -903,7 +903,7 @@ def _handle_config_settings(
     dest="root_user_action",
     default="warn",
     choices=["warn", "ignore"],
-    help="Action if pip is run as a root user. By default, a warning message is shown.",
+    help="Action if pip is run as a root user [warn, ignore] (default: warn)",
 )
 
 
diff --git a/src/pip/_internal/cli/req_command.py b/src/pip/_internal/cli/req_command.py
--- a/src/pip/_internal/cli/req_command.py
+++ b/src/pip/_internal/cli/req_command.py
@@ -219,9 +219,12 @@ def warn_if_run_as_root() -> None:
 
     logger.warning(
         "Running pip as the 'root' user can result in broken permissions and "
-        "conflicting behaviour with the system package manager. "
+        "conflicting behaviour with the system package manager, possibly "
+        "rendering your system unusable."
         "It is recommended to use a virtual environment instead: "
-        "https://pip.pypa.io/warnings/venv"
+        "https://pip.pypa.io/warnings/venv. "
+        "Use the --root-user-action option if you know what you are doing and "
+        "want to suppress this warning."
     )
 
 


Test patch: