4

I am trying to cache pip dependencies for later reuse with the following github actions workflow:

name: Preperation
on:
  workflow_call:
  workflow_dispatch:
  
jobs:
  preperation:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
        
      - name: Setup Python environment
        uses: actions/setup-python@v4
        with:
          python-version: 3.x
          cache: 'pip' # caching pip dependencies
      
      - name: Install Python dependencies
        run: pip install -r requirements.txt

However, the actions/setup-python step fails with the following error:

Successfully set up CPython (3.8.10)

/opt/github-action-runner/_work/_tool/Python/3.8.10/x64/bin/pip cache dir

WARNING: The directory '/home/github-action-runner/.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.

ERROR: pip cache commands can not function since cache is disabled.

Error: The process '/opt/github-action-runner/_work/_tool/Python/3.8.10/x64/bin/pip' failed with exit code 1

How can the cache be enabled on a GitHub actions runner?

2
  • I have the exact same issue, did you ever manage to fix it ? Commented Oct 12, 2022 at 10:45
  • 1
    No unfortunately not. Commented Oct 12, 2022 at 15:04

1 Answer 1

1
nano ~/.config/pip/pip.conf
nano ~/.pip/pip.conf

in files

#no-cache-dir = true

I commented the line in both files and my problem was solved.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.