Repository navigation
[BUG] setup-python fails across multiple Windows and action versions when caching is requested and newer pip outputs a deprecation warning (any really) #1034
Description
Activity
- added a commit that references this issue
on Feb 13, 2025 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.
Reacted by 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко)This is the line that the action hits in the broken scenario:
.`Could not get cache folder path for pip package manager` I tried various things so far.
Moving the requirements files mentioned in the
cache-dependency-pathto the top level of the repo does not help: https://github.com/aio-libs/frozenlist/actions/runs/13328642529/job/37227633874?pr=627#step:4:27. This excludes the possibility of this problem being related to non-normalized path separator (slash vs. backslash).Moving
setup-pythonbefore checkout makes it break due to the absence of the req files. This is expected.Deleting the
cacheandcache-dependency-pathinputs does work. So it's a viable workaround. https://github.com/aio-libs/frozenlist/actions/runs/13315768115/job/37189473317?pr=622#step:4:23In 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:
v5.0.0: https://github.com/aio-libs/frozenlist/actions/runs/13329181570/job/37229342141?pr=630#step:4:27
v4.0.0: https://github.com/aio-libs/frozenlist/actions/runs/13329182488/job/37229360342?pr=631#step:4:26I wonder if something changed in the recently published CPython builds…
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
setup-python-in that repo. I delete the other manually-managed Windows cache, but it did not do anything.I've checked frozenlist, and it does have caches prefixed with
setup-python-but not withsetup-python-Windows-. Can this be another bit of the puzzle? Does the reproducer require that there's no pre-existing cache saved?3 remaining items
Reading
, I have a theory of what's happening:setup-python/src/cache-distributions/pip-cache.ts
Lines 24 to 48 in 8039c45
let exitCode = 1; let stdout = ''; let stderr = ''; // Add temporary fix for Windows // On windows it is necessary to execute through an exec // because the getExecOutput gives a non zero code or writes to stderr for pip 22.0.2, // or spawn must be started with the shell option enabled for getExecOutput // Related issue: https://github.com/actions/setup-python/issues/328 if (IS_WINDOWS) { const execPromisify = utils.promisify(child_process.exec); ({stdout: stdout, stderr: stderr} = await execPromisify('pip cache dir')); } else { ({ stdout: stdout, stderr: stderr, exitCode: exitCode } = await exec.getExecOutput('pip cache dir')); } if (exitCode && stderr) { throw new Error( `Could not get cache folder path for pip package manager` ); } - There's
exitCode = 1at the beginning - But the windows branch does not set the return code, so it's always
1. - This means that
if (exitCode && stderr)is only influenced by stderr on Windows. - A new release of pip v25.0.1 got published on Feb 9.
- By default, pip prints out hints with "hey there's a new version available, wanna upgrade?" on any pip invocations.
- So when the action calls
pip cache dir, the bundled version of pip is older than the one on PyPI. - On Windows, that gets into
stderrbut the return code in the variable is not updated — it remains set to 1.
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.
- There's
- changed the title
[-]`Error: Could not get cache folder path for pip package manager` across multiple Windows and action versions today[/-][+]`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 published[/+]on Feb 16, 2025 - changed the title
[-]`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 published[/-][+][BUG] `setup-python` fails across multiple Windows and action versions when caching is requested and newer pip is published on PyPI[/+]on Feb 16, 2025 - changed the title
[-][BUG] `setup-python` fails across multiple Windows and action versions when caching is requested and newer pip is published on PyPI[/-][+][BUG] `setup-python` fails across multiple Windows and action versions when caching is requested and newer pip outputs a deprecation warning (any really)[/+]on Feb 16, 2025 The only thing I was incorrect about was the warning being output, it seems. It's not the upgrade hint, but a deprecation:
DEPRECATION: --no-python-version-warning is deprecated. pip 25.1 will enforce this behaviour change. A possible replacement is to remove the flag as it's a no-op. Discussion can be found at https://github.com/pypa/pip/issues/13154To anyone landing here from Google or hitting this bug otherwise
I'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
setup-pythonand after a sort of checkout (or similar).Hello @webknjaz , thank you for the detailed report.
The issue arises from the--no-python-version-warningflag, which has become redundant and is no longer functional. This flag now triggers a warning tostderrfrom pip, leading to the failure. We are continuing our investigation into the matter.As an immediate workaround, we recommend removing the
PIP_NO_PYTHON_VERSION_WARNINGenvironment variable. This will prevent the warning from being output tostderr, allowing your workflow to proceed without errors.Alternatively, for Windows environments, you can use the
actions/cacheaction after thesetup-pythonaction to manage caching. For more details, you can refer to the actions/cache documentation. Here is an example configuration:- 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.
setup-python's caching is not very sophisticated, anyway, and misses a few important points.- added 3 commits that reference this issue
on Feb 26, 2025 - added a commit that references this issue
on Mar 12, 2025 @webknjaz 👋,
The issue was originally caused by the--no-python-version-warningflag, which became redundant and triggered a warning frompip, leading to failures in workflows. However, the deprecation and removal of this flag has been reverted as per pypa/pip#13308. Going forward, the flag will be hidden from the CLI help and documentation, but it will no longer trigger errors or warnings.
Since the problem no longer persists, we are proceeding to close this issue. Please feel free to reach out if you have any concerns or need assistance.Yeah, I know about the changes in pip. Special-casing stderr in select envs remains weird still.
Anyway, my caching solution is better so I'll stick to it.
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-pythonand 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-pythonthreads any stderr frompipas 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-2019andwindows-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-pythonand 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@v5into a windows job, setPIP_NO_PYTHON_VERSION_WARNING: 1env var and add thecache: pipinput.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 versionsoutput, and crashes the job.