Skip to content

Suppress warnings during Python installation #513

Description

@ssalmani-ledger

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/venv warning (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.

image

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).

Activity

  1. vsafonkin commented on Sep 30, 2022

    @vsafonkin

    Hi @ssalmani-ledger, thank you for your suggestion, we will take a look at this.

  2. apowis commented on Sep 30, 2022

    @apowis

    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)

  3. Leseratte10 commented on Oct 18, 2022

    @Leseratte10

    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-warning to 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?

  4. jharris-tc commented on Nov 2, 2022

    @jharris-tc

    @vsafonkin

    hey, am I correct in that changing this function
    https://github.com/actions/setup-python/blob/main/src/install-pypy.ts#L151

    to check an env var/input and then add --root-user-action=ignore if its set would fix this?

  5. dmitry-shibanov commented on Mar 10, 2023

    @dmitry-shibanov
    Contributor

    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=ignore will 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.

  6. flipcc commented on May 15, 2023

    @flipcc

    I 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?

  7. dmitry-shibanov commented on May 15, 2023

    @dmitry-shibanov
    Contributor

    Hello @flipcc. You need to put this env variables on the job level.

  8. flipcc commented on May 15, 2023

    @flipcc

    I 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?

  9. bdlake commented on Jun 16, 2023

    @bdlake

    @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:latest docker image.

    Note: this error wasn't present on Github Hosted ubuntu:latest runners. Only when I switched to self-hosted. So I ended up installing python3.9 and python-pip as part of the Dockerfile and removed actions/setup-python@v4 from my workflow. All good now.

  10. dezren39 commented on Oct 5, 2023

    @dezren39

    this 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.

  11. andreas-aman commented on Oct 19, 2023

    @andreas-aman

    Can confirm that this is still an issue..
    @dmitry-shibanov Do you want us to open a new issue?

  12. diego-ppz commented on May 16, 2024

    @diego-ppz

    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.

  13. tamird commented on Jun 12, 2024

    @tamird

    I can confirm that

    env:
      PIP_ROOT_USER_ACTION: ignore
    

    doesn'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@v5
    

    EDIT: nope, I'm wrong. Can't silence this warning.

  14. diego-ppz commented on Jun 12, 2024

    @diego-ppz

    Not in self-managed runners
    Screenshot from 2024-06-12 11-05-15

  15. spencersmith commented on Jan 3, 2025

    @spencersmith

    Did 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.

  16. Mihoubi commented on Jan 11, 2025

    @Mihoubi

    By January 11 2025 I can confirm this issue is still happening even with the latest version v5.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or request to improve the current logic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions