Skip to content

Fix package update exitcode#13851

Open
lklivingstone wants to merge 2 commits intopypa:mainfrom
lklivingstone:fix/package-update-exitcode
Open

Fix package update exitcode#13851
lklivingstone wants to merge 2 commits intopypa:mainfrom
lklivingstone:fix/package-update-exitcode

Conversation

@lklivingstone
Copy link
Copy Markdown

Fixes: #13406

Summary

When running pip install --upgrade, if the package index cannot be accessed (e.g. due to invalid credentials or network errors) and the package is already installed, pip may incorrectly report “Requirement already satisfied” and exit with status code 0.

This change tracks index access failures during index page retrieval and records them on the PipSession. During candidate generation in the resolver, pip checks this flag and raises an InstallationError if the index could not be accessed and index candidates are required.

This ensures pip install --upgrade fails with a non-zero exit code when pip cannot access the configured package index to determine available versions.

Logs

Correct Password

(.venv) lk@lk-V:~/pip$ python -m pip install mylibrary --upgrade --index-url http://user:correctpassword@localhost:8080/simple
Looking in indexes: http://user:****@localhost:8080/simple
Requirement already satisfied: mylibrary in ./.venv/lib/python3.12/site-packages (1.0.0)
(.venv) lk@lk-V:~/pip$ echo $?
0

Incorrect Password

(.venv) lk@lk-V:~/pip$ python -m pip install mylibrary --upgrade --index-url http://user:wrongpassword@localhost:8080/simple
Looking in indexes: http://user:****@localhost:8080/simple
Requirement already satisfied: mylibrary in ./.venv/lib/python3.12/site-packages (1.0.0)
ERROR: Failed to access package index while checking for upgrades.
(.venv) lk@lk-V:~/pip$ echo $?
1

@notatallshaw
Copy link
Copy Markdown
Member

Thanks @lklivingstone for the PR, be aware review capacity is extremely limited at the moment, so it may take a bit for a maintainer to get to your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pip has the wrong exitcode when package-update is not possible

2 participants