setup-python
setup-python copied to clipboard
"pip cache is not found" (/home/runner/.cache/pip)
Maybe related, but not really: #816
Description:
I expect this action to create the directory for the pip cache, when I use cache: pip, but instead it displays this message.
Action version:
v5
Platform:
- [x] Ubuntu
- [ ] macOS
- [ ] Windows
Runner type:
- [x] Hosted
- [ ] Self-hosted
Tools version:
I used 3.7.17
Repro steps:
- uses: actions/setup-python@v5
with:
python-version: '3.7.17'
cache: 'pip'
Expected behavior:
Action creates the cache directory for the user (probably in /home/runner/.cache/pip).
Actual behavior:
It does not create the cache folder. Also, when I run this locally (with act), the post step fails because that.
Hello @till Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.
Hello @till, Thank you once again for creating this issue. Setup-python action sets up a Python environment and it doesn't create a pip cache directory by default. The pip cache directory is created when pip installs a package and needs to cache it. We tested the same by adding the pip installation job and pip cache file generated in the /home/runner/.cache/pip location and cached the pip installed packages. Also we are able to reproduce the error without adding the pip installation and pip hasn't cached any packages yet, so the cache directory doesn't exist. Please find the screenshots for reference.
- uses: actions/setup-python@v5
with:
python-version: '3.7.17'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- uses: actions/setup-python@v5
with:
python-version: '3.7.17'
cache: 'pip'
Please update the workflow as per the above and confirm.
@aparnajyothi-y what exactly are you asking me to do? Add a pip install something to confirm it gets created?
Hello @till, Add a job like below to your existing workflow to install dependency packages using pip to confirm.
- name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt
@aparnajyothi-y I won't get to that. I hope you don't need me to confirm.
The second bug (it fails the post step) is still there.
Somewhere in here: https://github.com/actions/setup-python/blob/main/src/cache-save.ts
Hello @till, we tried to reproduce the second issue but unfortunately we are not able to reproduce and the post step is successful. Please find the screenshot for reference.
Could you please share the repro link and the error that you are seeing in the post setup failure to further investigate.
Hello @till, Could you please share the repro link and the error that you are seeing in the post setup failure to further investigate.
Hello @till, Could you please share the repro link and the error that you are seeing in the post setup failure to further investigate.
@aparnajyothi-y no I can't. I don't know why you keep asking for it as you reproduced it above. I don't want to install dependencies with pip. In the end, I am trying to make it work for poetry, but there are other bugs preventing me from it.
This is all you need:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7.17'
cache: 'pip'
It shouldn't error in the post step. :) Maybe I am just installing python to run a one-liner, or whatever. Shouldn't assume that the directory is created, or ignore it when it's "not found".
@aparnajyothi-y, the reporter states that the post-step is failing when running the workflow locally using a third-party tool -- not from within GitHub workflows.
when I run this locally (with
act), the post step fails
(I'm assuming act refers to nektos/act.)
Hello @till, The error related to pipenv or poetry package managers cannot be changed to a warning due to the necessity of having the Pipfile.lock or poetry.lock file for caching in the actions/Setup-python.
To resolve this issue, please consider one of the following options:
Add the Pipfile.lock / poetry.lock file: Ensure that the Pipfile.lock file or poetry.lock is present in your repository. You can generate this file by running pipenv lock. Install dependencies: Make sure all required dependencies are installed and committed. Do not use cache: pip: If there are no dependencies to cache, remove the cache: pip configuration from your GitHub Actions workflow. Additionally, please note that changing this behaviour would require multiple code changes, which may be implemented as a feature request.
Hello @till, Please let us know if you need any more clarifications on the above comment :)
Same issue here. https://github.com/oldgithubman/displaycal-py3
Mainly trying to cache the wheel for wxPython after built, but the more I can cache, the better
Hello @till, we are proceeding to close this issue as we didn't hear anything from a long time. Please feel to reach us in case of any concerns to reopen this issue :)
Hello @till, we are proceeding to close this issue as we didn't hear anything from a long time. Please feel to reach us in case of any concerns to reopen this issue :)
@aparnajyothi-y I have the same problem. Can you help?
Hello @oldgithubman, We are happy to assist you with this issue. As mentioned above, the setup-python action sets up a Python environment but does not create a pip cache directory by default. The pip cache directory is created when pip installs a package and needs to cache it.
Based on the above attached screenshot, we tested this by adding a pip installation job. The pip cache file was generated in the /home/runner/.cache/pip location, and the installed packages were cached. We were also able to reproduce the error when the pip installation was not added, as pip had not cached any packages, and thus the cache directory did not exist.
Please feel free to reach out if any further clarifications are needed.