Skip to content

There was an error checking the latest version of pip #13352

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

Open
1 task done
levicki opened this issue Apr 26, 2025 · 6 comments
Open
1 task done

There was an error checking the latest version of pip #13352

levicki opened this issue Apr 26, 2025 · 6 comments
Labels
C: error messages Improving error messages resolution: deferred till PR Further discussion will happen when a PR is made type: bug A confirmed bug or unintended behavior

Comments

@levicki
Copy link

levicki commented Apr 26, 2025

Description

This is not a duplicate of previous identically named issues.

This still happens on Windows when package cache path set in the environment variable PIP_CACHE_DIR is not accessible for any reason.

Expected behavior

When running python -m pip install pip -U it is expected that it completes without errors. If it encounters errors those errors should be conveyed to the user in a meaningful way without the need to scour debug logs.

In this particular case, I would expect from the package manager to validate the package cache path set in the environment variable before trying to do anything else and if that path is inaccesible for whatever reason it should say so instead of giving a cryptic warning whose wording implies some sort of transient network error.

pip version

25.1

Python version

Python 3.12.10

OS

Windows 10/11

How to Reproduce

  1. Set PIP_CACHE_DIR to a non-existing path (for example D:\PACKAGES\pip if you don't have a D: drive)
  2. Run python -m pip install pip -U from command prompt

Note that the versions listed are probably not the only ones affected but are the ones I tested with.

Output

C:\Install>python --version
Python 3.12.10

C:\Install>ver

Microsoft Windows [Version 10.0.19044.5737]

C:\Install>python -m pip install pip -U
Requirement already satisfied: pip in c:\programs\python\lib\site-packages (25.1)
WARNING: There was an error checking the latest version of pip.

Here's also full debug output: debug.txt

From it we can see what the actual error is:

PermissionError: [WinError 5] Access is denied: 'd:\\packages'

In this case drive D: does not exist at all, so even the Windows error code seems misleading.

Code of Conduct

@levicki levicki added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Apr 26, 2025
@pfmoore
Copy link
Member

pfmoore commented Apr 26, 2025

This looks like pip is expecting its cache directory to be in a different place than the default. Did you at any stage move your Python installation from one drive to another? Or do you have a configuration file that overrides the default cache directory? What does pip config debug show?

@pradyunsg
Copy link
Member

Additionally, the logs of a run with --debug passed to pip install would be useful as well! (please post in a GitHub Gist, and paste the link here)

@pradyunsg pradyunsg added S: awaiting response Waiting for a response/more information and removed S: needs triage Issues/PRs that need to be triaged labels Apr 26, 2025
@ichard26 ichard26 added resolution: deferred till PR Further discussion will happen when a PR is made C: error messages Improving error messages and removed S: awaiting response Waiting for a response/more information labels Apr 26, 2025
@ichard26
Copy link
Member

ichard26 commented Apr 26, 2025

Pss. Both of your questions have already been answered in the original post.

This still happens on Windows when package cache path set in the environment variable PIP_CACHE_DIR is not accessible for any reason.

Here's also full debug output: debug.txt

I'd say that improving the error message when pip fails to check whether there is a newer version of pip available is a reasonable request. It's also rather low priority since it's just a warning and unlikely to cause problems. I suppose we could augment the error message with a simple "reason"

WARNING: There was an error checking the latest version of pip. (insufficient permission to access cache)

Or to be even more broad.

WARNING: There was an error checking the latest version of pip. (failed to read cache)

The bikeshedding can occur in the PR that improves the situation here, though. I am NOT married to my suggestions, at all.

@levicki
Copy link
Author

levicki commented Apr 27, 2025

@ichard26 Thank you for considering it.

As a user (and a developer), I do have a slightly different view on how this should be fixed.

Ideally, the check whether package cache directory is accessible should be done before doing anything else, and user should be forced to remedy the situation by setting a valid PIP_CACHE_DIR (or unset the invalid one and fall back to default) before proceeding unless --no-cache-dir was present on the command line.

The error message text also needs improvement.

The whole concept of saying "WARNING: There was an error doing x" mixes different problem severities in the same sentence. If there was an error then severity should be ERROR, not a WARNING. Different wording can help resolve this ambiguity.

Your suggestion:

WARNING: There was an error checking the latest version of pip. (failed to read cache)

Still doesn't seem to tell the truth — If I am not mistaken pip did check online and determine the package is the latest one, it just failed to check/update the cache.

I understand that you might not want to change the behavior from warning to error when cache dir is inaccesible because of scripting that might break. The decision whether to potentially break scripting by converting this warning into an error boils down to answering the question whether denying access to pip cache dir can help faciliate supply chain attacks. I am not an expert on the subject, but I think the risk is there so if by any chance you decide to do so, then the error message could be:

ERROR: PIP_CACHE_DIR is inaccessible, please fix and re-run the command

Otherwise, if you stick with a warning:

WARNING: PIP_CACHE_DIR is inaccessible, all package operations will use online source(s)

Of course, warning should be suppressed if --no-cache-dir was present on the command line.

Whatever you decide to do, I'd suggest "failed to do x" over "there was an error doing x" — active .vs. passive voice is much clearer and shorter.

@potiuk
Copy link
Contributor

potiuk commented Apr 27, 2025

Whatever you decide to do, I'd suggest "failed to do x" over "there was an error doing x" — active .vs. passive voice is much clearer and shorter.

Good suggestions - why don't you propose a PR and lead it to completion @levicki -> that would be nice contribution back

@levicki
Copy link
Author

levicki commented Apr 27, 2025

Good suggestions - why don't you propose a PR and lead it to completion @levicki -> that would be nice contribution back

I woouldn't want to waste time making a PR that could potentially cause breakage by behavior change without maintainers chiming in first. I'd like to hear what they think about the potential security angle of this issue first.

That said, I wouldn't mind even though I am not familiar with the codebase or build system and I could probably only test the Windows part at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: error messages Improving error messages resolution: deferred till PR Further discussion will happen when a PR is made type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

5 participants