-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] setup-python
fails across multiple Windows and action versions when caching is requested and newer pip outputs a deprecation warning (any really)
#1034
Comments
This is an experimental attempt to work around the bug in `actions/setup-python@v5` [[1]]. [1]: actions/setup-python#1034
So this experiment shows that dropping the cache inputs makes it pass: aio-libs/frozenlist#622. |
Hi @webknjaz ,Thank you for creating this issue. We will investigate it and provide feedback as soon as we have some updates. |
This is the line that the action hits in the broken scenario:
I tried various things so far. Moving the requirements files mentioned in the Moving Deleting the |
In an attempt to bisect the problem, I tried v5.2.0 (https://github.com/aio-libs/frozenlist/actions/runs/13328934530/job/37228641891?pr=629#step:4:27) and v5.1.0 (https://github.com/aio-libs/frozenlist/actions/runs/13328909086/job/37228544936?pr=628#step:4:27). Both are still broken. Can the cache be corrupted somehow? |
Older action versions are broken the same way: I wonder if something changed in the recently published CPython builds… |
Nope... Requesting Python 3.13.0 published a while back (instead of 3.13.2) still results in an error: https://github.com/aio-libs/frozenlist/actions/runs/13329352448/job/37229847658#step:4:165 |
I thought that manual cache invalidation would help, but when I've gone to delete it in Cheroot, I realized that there's no cache prefixed with I've checked frozenlist, and it does have caches prefixed with |
The upstream `actions/setup-python` has rudimentary support for cache management but it's rather limited. It also has bugs in caching [[1]]. Having own reusable cache computation bit gives us better level of control, letting us make cache depend on specific Python runtime features. [1]: actions/setup-python#1034
The upstream `actions/setup-python` has rudimentary support for cache management but it's rather limited. It also has bugs in caching [[1]]. Having own reusable cache computation bit gives us better level of control, letting us make cache depend on specific Python runtime features. [1]: actions/setup-python#1034
The upstream `actions/setup-python` has rudimentary support for cache management but it's rather limited. It also has bugs in caching [[1]]. Having own reusable cache computation bit gives us better level of control, letting us make cache depend on specific Python runtime features. [1]: actions/setup-python#1034
The upstream `actions/setup-python` has rudimentary support for cache management but it's rather limited. It also has bugs in caching [[1]]. Having own reusable cache computation bit gives us better level of control, letting us make cache depend on specific Python runtime features. [1]: actions/setup-python#1034
The upstream `actions/setup-python` has rudimentary support for cache management but it's rather limited. It also has bugs in caching [[1]]. Having own reusable cache computation bit gives us better level of control, letting us make cache depend on specific Python runtime features. [1]: actions/setup-python#1034
The upstream `actions/setup-python` has rudimentary support for cache management but it's rather limited. It also has bugs in caching [[1]]. Having own reusable cache computation bit gives us better level of control, letting us make cache depend on specific Python runtime features. [1]: actions/setup-python#1034
Reading setup-python/src/cache-distributions/pip-cache.ts Lines 24 to 48 in 8039c45
To summarize, this corner case is triggered on Windows but not *NIX, whenever a new version of pip is published to PyPI, but the respective Python build from https://github.com/actions/python-versions ships older pip. That older pip would print upgrade hints, which setup-python would misinterpret as error output on Windows. This bug has been introduced by #332. |
Error: Could not get cache folder path for pip package manager
across multiple Windows and action versions todayError: Could not get cache folder path for pip package manager
across multiple Windows and action versions when caching is enabled and new pip is published
Error: Could not get cache folder path for pip package manager
across multiple Windows and action versions when caching is enabled and new pip is publishedsetup-python
fails across multiple Windows and action versions when caching is requested and newer pip is published on PyPI
setup-python
fails across multiple Windows and action versions when caching is requested and newer pip is published on PyPIsetup-python
fails across multiple Windows and action versions when caching is requested and newer pip outputs a deprecation warning (any really)
The only thing I was incorrect about was the warning being output, it seems. It's not the upgrade hint, but a deprecation:
|
To anyone landing here from Google or hitting this bug otherwiseI've been wanting better cache control for quite a while, so I've wrapped what I've been doing for years into a more reusable component — a composite action that can sense whether it's safe to cache things based on the current runtime stability (ABI stability is computed based on the version being marked as final). Feel free to make use of it: https://github.com/re-actors/cache-python-deps. The sample use would be - name: Restore pip cache
uses: re-actors/cache-python-deps@release/v1
with:
cache-key-for-dependency-files: >-
${{
hashFiles(
'.pre-commit-config.yaml',
'requirements/**',
'tox.ini',
'tox.toml',
'pyproject.toml'
)
}} provided that it's invoked after |
Hello @webknjaz , thank you for the detailed report. As an immediate workaround, we recommend removing the Alternatively, for Windows environments, you can use the - name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
|
@priyagupta108 yes, I know. I'm using it like that. Just made a wrapper action to abstract away a few other caching quirks better that |
UPD(17.02.2025): To anyone landing here from Google or hitting this bug otherwise
Tip
Here's the solution I landed on, not only because of just this bug, but I've also been wanting better cache control for quite a while, so I've wrapped what I've been copying and pasting for years into a more reusable component — a composite action that can sense whether it's safe to cache things based on the current runtime stability (ABI stability is computed based on the version being marked as final). Feel free to make use of it: https://github.com/re-actors/cache-python-deps.
The sample use would be
provided that it's invoked after
setup-python
and after a sort of checkout (or similar). Integration example: aio-libs/frozenlist#622 / aio-libs/frozenlist#633.P.S. The root cause of the bug is that
setup-python
threads any stderr frompip
as a failure in any Windows runtimes. New pip started outputting a warning about a CLI flag being deprecated. That CLI flag is often being set via env vars likePIP_NO_PYTHON_VERSION_WARNING
(meant to suppress another warning in the output). More explanation here: #1034 (comment).Description:
I've been updating a few GHA configurations today and in the process saw the same error in several places. Interestingly, in some repos it fails in one workflow but works in another. I've been seeing this for the past few hours, but this is in repos I haven't touched in months, so the issue might've appeared earlier.
I've tried finding differences and similarities, but cannot say anything definitive.
Among the similarities, there's these:
Also, the action fails on both
windows-2019
andwindows-2022
. It fails in matrixes that pass a variety of Python versions, starting with 3.9 and all the way to 3.13.Another bit I noticed was that some of the jobs downloaded immutable actions, while others fetched from Git. But there's examples of both in failing/passing action invocations.
Failing job examples (there's more in the same workflow runs):
Success example:
As you can see, there's successes and failures in the same repo, just different job definitions.
While writing this, I also noticed that the failing ones have some sort of file preparation before calling
setup-python
and caching args enabled. Worth checking out... I'll report back once I experiment some more.Action version:
v5
Platform:
Runner type:
Tools version:
🤷♂ seems to be any Python version and any windows image.
Repro steps:
Add a step with
actions/setup-python@v5
into a windows job, setPIP_NO_PYTHON_VERSION_WARNING: 1
env var and add thecache: pip
input.Expected behavior:
It should succeed.
Actual behavior:
The action spits out
Error: Could not get cache folder path for pip package manager
, after the successfulInstalled versions
output, and crashes the job.The text was updated successfully, but these errors were encountered: