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?