Skip to content

Fix constraint file open error message - #13797

Merged
pfmoore merged 2 commits into
pypa:mainfrom
gcomneno:pr-13226-constraint-error
Feb 10, 2026
Merged

Fix constraint file open error message#13797
pfmoore merged 2 commits into
pypa:mainfrom
gcomneno:pr-13226-constraint-error

Conversation

@gcomneno

Copy link
Copy Markdown
Contributor

Fixes #13226.

When a constraint file path is missing/unreadable (via -c/--constraint or PIP_CONSTRAINT), pip reported "Could not open requirements file", which is misleading.

This change passes the existing constraint context into get_file_content() and tailors the InstallationError message to say "constraint file" when appropriate.

Tests: add a unit test asserting the correct message for constraint=True.

@gcomneno

Copy link
Copy Markdown
Contributor Author

Thanks! FYI, earlier CI noise was due to aligning the Towncrier fragment naming with Chronographer and whitelisting news/** as git-only for check-sdist (fragments are dev-only, not included in sdist). Latest head is green.

Comment thread pyproject.toml Outdated
@@ -380,6 +380,7 @@ exclude_also = [
git-only = [
"tests/**",
"tools/**",
"news/**",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of this change? It seems unrelated to the purpose of the PR.

@gcomneno

Copy link
Copy Markdown
Contributor Author

Good point - it isn’t directly related to the UX fix. I added it while addressing CI failures around the Towncrier fragment, but I agree it’s scope creep for this PR. I’ve reverted the check-sdist change; if the project wants an explicit adjustment for Towncrier fragments, I can follow up with a dedicated PR.

@pfmoore

pfmoore commented Feb 10, 2026

Copy link
Copy Markdown
Member

Your NEWS entry is named incorrectly. See here:

If your issue or PR number is 1234 and this change is fixing a bug, then you would create a file news/1234.bugfix.rst.

Please fix the filename and rebase the PR to remove the spurious commits messing with the news file and whitelisting.

@gcomneno

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I've renamed the news fragment to news/13226.bugfix.rst and rebased to drop the intermediate/spurious commits. Latest head is green.

@pfmoore
pfmoore merged commit 2c1f59f into pypa:main Feb 10, 2026
28 checks passed
@pfmoore

pfmoore commented Feb 10, 2026

Copy link
Copy Markdown
Member

Thanks for the fix for this small, but annoying, issue! 🙂

@gcomneno
gcomneno deleted the pr-13226-constraint-error branch February 23, 2026 18:16
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UX] Constraint file lookup error message is misleading (a troubleshooting adventure)

2 participants