Closed kostrykin closed 2 months ago
Hello @kostrykin Thank you for creating this feature request. We will investigate it and get back to you as soon as we have some feedback.
I see this error as well with a GH runner and setup-python@v5.
Current runner version: '2.313.0'
Runner name: 'ubuntu-64-core_52f54d836f2b'
- name: Set up python
uses: actions/setup-python@v5
env:
PIP_ROOT_USER_ACTION: ignore
with:
python-version-file: "${{ github.workspace }}/.python-version"
Version 3.9.13 was not found in the local cache
Version 3.9.13 is available for downloading
Download from "https://github.com/actions/python-versions/releases/download/3.9.13-2717571420/python-3.9.13-linux-22.04-x64.tar.gz"
Extract downloaded archive
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /__w/_temp/748f9721-eda0-46d4-9ef8-998917524fe8 -f /__w/_temp/f7bf8f82-a8c6-4bbf-bb5b-37fe58a73ad4
Execute installation script
Check if Python hostedtoolcache folder exist...
Create Python 3.9.13 folder
Copy Python binaries to hostedtoolcache folder
Create additional symlinks (Required for the UsePythonVersion Azure Pipelines task and the setup-python GitHub Action)
Upgrading pip...
Looking in links: /tmp/tmpoatwhyci
Requirement already satisfied: setuptools in /__t/Python/3.9.13/x64/lib/python3.9/site-packages (58.1.0)
Requirement already satisfied: pip in /__t/Python/3.9.13/x64/lib/python3.9/site-packages (22.0.4)
Error: 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
Error: WARNING: The directory '/github/home/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Collecting pip
Downloading pip-24.0-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 17.6 MB/s eta 0:00:00
Installing collected packages: pip
Successfully installed pip-24.0
Error: 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
Create complete file
Successfully set up CPython (3.9.13)
One of the classical issues with self-hosted runners.
This BTW happens for any tool installation that happens inside a container, as the tool is saved in the toolcache by the container user (as the action is executed inside the container by the nodejs mounted at /__e
) so, in most cases, root
.
If container use is a requirement, prefer container's native package management or even better use directly library/python:3.11
.
If you are using self-hosted runners to run containerized jobs that install things using js actions, the only solution I found is to add a cron in the runner VM to chown -R $RUNNERUSER /opt/actions-runner/_work/_tool/*
that is executed every minute.
PS out-of-topic: IMHO self-hosted runners are a painful mess of technical debt. I suggest to add daily crons for:
find /opt/actions-runner/_work/_temp/ -type d -mtime +2 ! -name '*runner*' ! -name '*home*' -exec rm -rf {} \;
(tempdir cleanup)find /opt/actions-runner/_diag/ -type d -mtime +2 -exec rm -rf {} \;
(logs cleanup)find /opt/actions-runner/_work/[a-z]* -mindepth 1 -maxdepth 1 -mtime +2 -exec rm -rf {} \;
(workspace dirs cleanup)But -spoiler- this is only a start, be ready to modify your preferred checkout action with a $HOME override if inside a container.
Hello @kostrykin, We have investigated the issue and found that the error occurs when the current user doesn't have write permissions to the specified directory. In the context of docker, this issue is related to how the container is set up and the user that the container is running as. The root cause of the issue could be related to how the container and user are set up. If the issue persists, we might need to look into configuring the docker container to run as a specific user that has the necessary permissions. The workaround to resolve this issue, please add a step in the workflow to change the ownership of the /github/home directory to the current user before running actions/setup-python. Here's an example of how you could do this: jobs: testjob: name: Compute results runs-on: self-hosted container: image: ubuntu:20.04 steps:
name: Checkout uses: actions/checkout@v2
name: Change ownership of /github/home run: sudo chown -R $(whoami) /github/home
uses: actions/setup-python@v5 with: python-version: '3.8.5' This will change the ownership of the /github/home directory to the current user, which should resolve the permission issue when setup-python tries to use the /github/home/.cache/pip directory. Please reach us in case further clarification needed.
Hello @kostrykin, Please confirm that the above mentioned workaround resolved the '/github/home/.cache/pip' or its parent directory is not owned or is not writable by the current user issue.
Thanks for the investigation @aparnajyothi-y
I will try the suggested workaround within the next couple of days and report then.
Hello @kostrykin, Please confirm that the above mentioned workaround resolved the issue.
Hello @kostrykin, Please confirm that the above mentioned workaround resolved the issue or let us know in case any further clarifications needed.
I tried to reproduce the issue again which I reported originally.
I had to use a newer docker image ubuntu:22.04
because with ubuntu:20.04
pip complained about outdated SSL certificates. As a result, I also had to use a newer Python version, that is 3.8.12
instead of 3.8.5.
. I also pinned actions/setup-python
to v5.1.0
.
With this configuration, I couldn't reproduce the issue, the setup-python action worked nicely.
If someone stumbles over this and wants to look into the details: I tested the changes in https://github.com/BMCV/SuperDSM/pull/12. There were some other issues, which is why I closed the PR, but those were unrelated to the setup-python action.
Hello @kostrykin, Thank you for confirming that actions/setup-python is working successfully. We are proceeding to close this issue as it is not reproducible. Please feel free to reach out if you need any further support or assistance.
Description: I'm trying to use the setup-python action using a freshly setup self-hosted runner and a container image:
This leads to the following docker invocation:
In the next step, the setup-python action yields the error:
When I create the docker container using the command cited above manually, I can inspect the directory
/github/home
:Touching/removing the contents of
/github/home
also works just fine, so there seems to be no permission issue.The runner is running wird UID 1002 and GID 1003.
Running the action without a container results in a different error (
mkdir: cannot create directory ‘/Python’
) which I think is because it attempts to modify the host root filesystem, for which the user with UID 1002 lacks permissions (which is intended).Action version: 5
Platform:
Runner type:
Tools version: 3.8.x
Full log of the action: