Repository navigation
Suppress warnings during Python installation #513
Description
Activity
- addedfeature requestNew feature or request to improve the current logicNew feature or request to improve the current logic
on Sep 30, 2022 Hi @ssalmani-ledger, thank you for your suggestion, we will take a look at this.
Similarly, I am seeing a warning for the pip version, despite it upgrading it:
WARNING: You are using pip version 21.1.1; however, version 22.2.2 is available. You should consider upgrading via the '/opt/hostedtoolcache/Python/3.9.5/x64/bin/python -m pip install --upgrade pip' command.(apologies if this is unrelated)
Similar suggestion, I'm using this action to setup python 2 and I always get the Python 2 deprecation warning in the Github Annotations:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
I know that Python 2 is deprecated - I'm using this action to run automated tests on my python code and these need to run in Python 2 and Python 3 so I know my code works in both.
- name: Setup Python 2 uses: actions/setup-python@v3 with: python-version: '2.x'
For normal "pip" without this module, I can add the option
--no-python-version-warningto make it shut up about Python 2 being deprecated, but I found no option for this action to add custom parameters to the Pip call, nor did I find a dedicated option to make it not output these deprecation warnings.Can this be added?
hey, am I correct in that changing this function
https://github.com/actions/setup-python/blob/main/src/install-pypy.ts#L151to check an env var/input and then add
--root-user-action=ignoreif its set would fix this?Hello everyone. For now I'm going to close the feature request because we're not planing to add the separate input to pass parameters for pip.
We added logic for scripts to ignore the majority warnings and
--root-user-action=ignorewill be added for the next versions. For now you can specify global env variables to achieve the same behaviour:env: PIP_DISABLE_PIP_VERSION_CHECK: 1 PIP_NO_PYTHON_VERSION_WARNING: 1 PIP_ROOT_USER_ACTION: ignore
@Leseratte10 Unfortunately for older pip versions this option does not work.
Reacted by Surya, Mohamed Mihoubi and digvijayvmlI also have a self-hosted runner on EC2. My configuration is as suggested:
- name: Set up Python 3.8 uses: actions/setup-python@v4 with: python-version: '3.8' env: PIP_ROOT_USER_ACTION: ignore
Yet still the warning persists. @dmitry-shibanov do I understand you correctly and the next release is what I have to wait for?
Hello @flipcc. You need to put this env variables on the job level.
Reacted by flipccI set the env var at step level, at job level and I tried adding it to $GITHUB_ENV in preparation, but the action does not seem to consider environment variables. @ssalmani-ledger did you ever suppress the warning?
Reacted by josephtole, Olivia Moses, Ben Lake, christinawongseequent, Surya, Diego Ruiz and RoFz@dmitry-shibanov I can also confirm the following doesn't work as the error persists:
jobs: run-tests: runs-on: [self-hosted, spot] env: PIP_ROOT_USER_ACTION: ignore steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: "3.9"
I tried on step, job, and global level - all still show the error.
I'm using a self-hosted runner using
ubuntu:latestdocker image.Note: this error wasn't present on Github Hosted
ubuntu:latestrunners. Only when I switched to self-hosted. So I ended up installingpython3.9andpython-pipas part of theDockerfileand removedactions/setup-python@v4from my workflow. All good now.Reacted by christinawongseequent and Drewry Popethis issue still occurs with self-hosted runners. it doesn't happen every time, just sometimes. in a dozen jobs maybe 2-4 will show this message. They all are the same runner type.
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
env: PIP_ROOT_USER_ACTION: "ignore" jobs: initial: runs-on: [self-hosted,Linux,Standard,X64] defaults: run: shell: pwsh env: PIP_ROOT_USER_ACTION: "ignore" steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 1 - name: Setup Python uses: actions/[email protected] with: python-version: '3.x'i can make a new issue if that would be better.
Can confirm that this is still an issue..
@dmitry-shibanov Do you want us to open a new issue?By May 16th 2024 I can confirm this issue is still happening.
Cannot get rid of the error no matter where I set up the environment variables to silence it.Reacted by Drew YangI can confirm that
env: PIP_ROOT_USER_ACTION: ignoredoesn't solve the problem. But I find that this does:
steps: - run: echo PIP_ROOT_USER_ACTION=ignore >> $GITHUB_ENV shell: bash - uses: actions/setup-python@v5EDIT: nope, I'm wrong. Can't silence this warning.
Reacted by Diego RuizDid anyone find a resolution to this issue? As far as I can see it's still happening. The issue referenced in #930 is a different warning so the accepted solution there doesn't apply here.
By January 11 2025 I can confirm this issue is still happening even with the latest version v5.3.0.

Description:
Have an option to suppress warnings during Python installation.
Justification:
I'm using self-hosted runners in EC2 and I have constantly the
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/venvwarning (which is capture by GitHub actions as an error). It would be nice to have an option to suppress these warnings so that these errors are not mixed up with the other warnings raised in the other steps.Note: It's also not possible for me to use a non-root user when running the workflow in the EC2 instance, as explained here: machulav/ec2-github-runner#64 (comment).