GithubHelp home page GithubHelp logo

The directory '/github/home/.cache/pip' or its parent directory is not owned or is not writable by the current user about setup-python HOT 10 CLOSED

kostrykin avatar kostrykin commented on September 21, 2024
The directory '/github/home/.cache/pip' or its parent directory is not owned or is not writable by the current user

from setup-python.

Comments (10)

danielefranceschi avatar danielefranceschi commented on September 21, 2024 1

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.

from setup-python.

aparnajyothi-y avatar aparnajyothi-y commented on September 21, 2024 1

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.

from setup-python.

HarithaVattikuti avatar HarithaVattikuti commented on September 21, 2024

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.

from setup-python.

ablatner avatar ablatner commented on September 21, 2024

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)

from setup-python.

aparnajyothi-y avatar aparnajyothi-y commented on September 21, 2024

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.

from setup-python.

kostrykin avatar kostrykin commented on September 21, 2024

Thanks for the investigation @aparnajyothi-y

I will try the suggested workaround within the next couple of days and report then.

from setup-python.

aparnajyothi-y avatar aparnajyothi-y commented on September 21, 2024

Hello @kostrykin, Please confirm that the above mentioned workaround resolved the issue.

from setup-python.

aparnajyothi-y avatar aparnajyothi-y commented on September 21, 2024

Hello @kostrykin, Please confirm that the above mentioned workaround resolved the issue or let us know in case any further clarifications needed.

from setup-python.

kostrykin avatar kostrykin commented on September 21, 2024

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 BMCV/SuperDSM#12. There were some other issues, which is why I closed the PR, but those were unrelated to the setup-python action.

from setup-python.

aparnajyothi-y avatar aparnajyothi-y commented on September 21, 2024

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.

from setup-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.