Open jb-2020 opened 1 month ago
Hello @jb-2020, Thank you for creating the issue and we will look into it :)
I think I may have just recreated the issue at https://github.com/hamirmahal/cache-pip-install/actions/runs/8962394394/job/24611209444.
name: Run
on: [push]
jobs:
python-program:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
cache: "pip"
python-version: "3.x"
- run: python3 src/main.py
results in
Error: Cache folder path is retrieved for pip but doesn't exist on disk: /home/runner/.cache/pip
name: Run on: [push] jobs: python-program: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: cache: "pip" python-version: "3.x" - run: python3 src/main.py
results in
Error: Cache folder path is retrieved for pip but doesn't exist on disk: /home/runner/.cache/pip
Thanks for checking it out @hamirmahal worth noting that our error messages are different and in our case it is a fatal error:
Unable to locate executable file: pip.
Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable.
Also check the file mode to verify the file is executable.
Looking at your workflow, I think setup-python
did manage to find the executable file?
Hi @jb-2020, I have attempted to reproduce the issue on my end, but was unable to do so. In our test environment, we have used pip cache without any errors, Here's a screenshot for your reference. Could you assist by sharing a link to a simplified version that reproduces the problem? Thank you!
jobs:
test:
runs-on: self-hosted
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: 'pip'
- name: Display Python version
run: python --version
- name: Check pip
run: |
which pip
pip --version
Thanking for checking it out, since we are in an air-gaped environment we are pulling:
python-${PYTHON_VERSION}-linux-22.04-x64.tar.gz
from a proxy of https://github.com/actions/python-versions/
Then populating the tools cache with:
mkdir -p ${RUNNER_TOOL_CACHE}/Python/${{ inputs.python-version }}/x64
tar -xzf python-${{ inputs.python-version }}.tar.gz --directory ${RUNNER_TOOL_CACHE}/Python/${{ inputs.python-version }}/x64
touch ${RUNNER_TOOL_CACHE}/Python/${{ inputs.python-version }}/x64.complete
rm -f python-${{ inputs.python-version }}.tar.gz
Which does install correctly, but pip isn't found. Any thoughts on this approach?
Hi @jb-2020 , We have followed the approach mentioned in the above comment and successful install the python and used the pip cache without any errors. Here's a screenshot and workflow file for your reference.
- name: Set up Python
run: |
PYTHON_VERSION=3.9.5
RUNNER_TOOL_CACHE=/home/azureuser/actions-runner/_work/_temp
mkdir -p ${RUNNER_TOOL_CACHE}/Python/${PYTHON_VERSION}/x64
curl -O https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz
tar -xzf Python-${PYTHON_VERSION}.tgz --directory ${RUNNER_TOOL_CACHE}/Python/${PYTHON_VERSION}/x64
touch ${RUNNER_TOOL_CACHE}/Python/${PYTHON_VERSION}/x64.complete
rm -f Python-${PYTHON_VERSION}.tgz
- name: Cache pip packages
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
- name: Verify Python Installation
run: |
python3 --version
Here are a few solutions which might reslove this issue.
Hi @jb-2020, Just a gentle reminder regarding this issue, If you have any updates or need further assistance, Please let us know.
Description:
We're on GHES and using self-hosted runners. We're using this action successfully by populating the
RUNNER_TOOL_CACHE
with our version sourced from a github-proxy ofactions/python-versions
.:Unfortunately, after attempting to use the
pip
cache we receive the following error:For what its worth, after running setup-python without the cache flag enabled I added a couple steps to the workflow to view the behavior of pip:
I've verified the appropriate environment variable as well:
RUNNER_TOOL_CACHE=/home/runner/_work/_tool
Action version:
actions/setup-python@v4
- This is the latest available on our version of GHES.Platform:
Runner type:
Tools version: 3.12.0
Repro steps:
This doesn't appear to have been reported in the past, looking for pointers in the right direction to determine if this is an issue in our runner environment.
Expected behavior: Cache to work as expected
Actual behavior: See above