Skip to content

Unsuppressed warnings about running pip as the root user when using self-hosted runners #1217

Closed

Description

@zvickery

Description:
I'm using the setup-python action with CodeBuild self-hosted runners. This works great but does output this warning:

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

This problem has been brought up (but not fixed) by past issues:

There appears to be no way to suppress this warning when using a self-hosted runner. After debugging this, I believe it is happening because ensurepip is being needlessly invoked in the install script: https://github.com/actions/python-versions/blob/main/installers/nix-setup-template.sh#L54

In ticket #930 it was correctly noted that ensurepip does not honor the PIP_ROOT_USER_ACTION environment variable. I have also confirmed that it is ensurepip (and not pip) producing these warnings. I asked the cpython team about this and as I understand, ensurepip should only be invoked when initially building python. Because the actions script installs a pre-built python, the call to ensurepip is not needed and can be removed.

AFAICT there is no specific reason this call is included in the script. Any objection to removing it?

Action version:
v6 and v5 for sure, seemingly others too

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:
3.11, 3.12, 3.13 for sure

Repro steps:
Just create a step that installs python while running on a CodeBuild-hosted Github Actions runner. Likely will also repro with other types of self-hosted runners too.

- name: Set up Python 3.13
  uses: actions/setup-python@v6
  with:
    python-version: 3.13

Expected behavior:
Python installs with no warnings

Actual behavior:
Python installs and works well, but prints the below warning:
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

Activity

  1. added
    bug
    on Sep 26, 2025
  2. v-gowridurgad commented on Sep 29, 2025

    @v-gowridurgad
    Contributor

    Hi @zvickery,
    Thank you for creating this issue. We will investigate it and provide feedback as soon as we have some updates.

  3. self-assigned this
    on Sep 29, 2025
  4. v-lmvysakh commented on Nov 3, 2025

    @v-lmvysakh
    Contributor

    Hi @zvickery,

    Thank you for raising this issue. We want to assure you that we are actively investigating the root cause and are working towards a resolution. We appreciate your patience and the detailed information provided from your end. We'll keep you updated here as we make progress and will notify you once a solution is available. If you have any additional insights or observations in the meantime, please feel free to share them.

  5. v-lmvysakh commented on Nov 18, 2025

    @v-lmvysakh
    Contributor

    Hi everyone,

    As we continue to investigate this warning with self-hosted runners, we would appreciate your feedback on whether you have encountered a similar issue when using Windows or macOS environments with the setup-python action. If you have experienced this warning on these platforms, could you please share your observations and any relevant details? Your input will help us ensure a comprehensive resolution across all environments.

    Thank you in advance for your time and feedback!

  6. zvickery commented on Nov 20, 2025

    @zvickery
    Author

    I personally only use Linux and am unaware of the behavior on other platforms.

  7. ersanhumeyra-boop commented on Nov 20, 2025

    @ersanhumeyra-boop
  8. v-lmvysakh commented on Dec 4, 2025

    @v-lmvysakh
    Contributor

    Hi @zvickery,

    Thank you for reporting this issue and for providing such a thorough analysis of the ensurepip-related warning on self-hosted runners. We wanted to let you know that we have already raised a main PR to address this problem by conditionally skipping the unnecessary invocation of ensurepip. You can follow the progress and discussion here: PR 369.

    We appreciate your patience and will keep you updated with any further changes or developments. Thank you again for your detailed feedback and engagement!

  9. v-priyagupta108 commented on May 15, 2026

    @v-priyagupta108
    Contributor

    @zvickery,
    We’ve opened another PR actions/python-versions#392 with an alternative approach to address the warning from the setup-python side by avoiding ensurepip when possible.
    Please take a look when you have a chance, and let us know if there’s anything we should adjust.

  10. zvickery commented on May 15, 2026

    @zvickery
    Author

    @zvickery, We’ve opened another PR actions/python-versions#392 with an alternative approach to address the warning from the setup-python side by avoiding ensurepip when possible. Please take a look when you have a chance, and let us know if there’s anything we should adjust.

    Seems great, thank you! If there is an way to test it I'm happy to do so

  11. removed their assignment
    on May 28, 2026
  12. v-priyagupta108 commented on May 28, 2026

    @v-priyagupta108
    Contributor

    Hi 👋

    This has been addressed! The fix is merged into actions/python-versions as part of PR #392. Going forward, new Python version binaries will ship with this fix and the root user warning on self-hosted runners will no longer appear.

    We're closing this issue. Please feel free to reach out if you have any questions or need further assistance.

    Thanks again for the detailed report and repro steps!

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

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions