Skip to content

Update DiagnosticPipError to add details_link to errors#14002

Open
polkapolka wants to merge 4 commits into
pypa:mainfrom
polkapolka:error-details-link
Open

Update DiagnosticPipError to add details_link to errors#14002
polkapolka wants to merge 4 commits into
pypa:mainfrom
polkapolka:error-details-link

Conversation

@polkapolka
Copy link
Copy Markdown

Resolves #10421

Thanks @pradyunsg and @sirosen ! At the PyCon US 2026 sprints, and implementing a first pass at the feature Pradyun mentioned at the Packaging Summit. Improving the error code messages in PIP by allowing a link to documentation on pypa which can describe the context of changes and suggest potential mitigations.

There are three open questions I have from this work.

Q1: Should there be more or different testing?

  • Right now, there are no new tests.
  • Existing tests have been updated to pass.

Q2: Hardcoding the link to the stable readthedocs site?

  • This is a fixed link in the error class. Should it be made dynamic for different contexts?

Q3: Chose to add new attribute .details_link, rather than reusing .link. Is that right?

  • Adding a new attribute is "safer" -- won't have any side-effects on existing code
  • Do we actually need that safety? Maybe .link is fine?

Please review the descriptions of the error references on errors.md, and let me know whether my descriptions need work.

@polkapolka polkapolka force-pushed the error-details-link branch from 55edfb4 to 84deca7 Compare May 20, 2026 01:35
@polkapolka polkapolka marked this pull request as ready for review May 20, 2026 01:38
@pradyunsg
Copy link
Copy Markdown
Member

Q1: Should there be more or different testing?

This feels... fine? I do feel like we should adopt https://diagnostic.readthedocs.io/en/latest/diagnostic.check.html eventually but not adopting it now seems fine. 😅

Q2: Hardcoding the link to the stable readthedocs site?

I suggest updating https://github.com/pypa/pip/blob/main/.readthedocs-custom-redirects.yml

Q3: Chose to add new attribute .details_link, rather than reusing .link. Is that right?

Seems very reasonable to me! We can change things at a future date, if/when we migrate over to diagnostic. 😅

Copy link
Copy Markdown
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

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

I didn't make it through everything, mostly because I'm rushing to a family thing now. 😅

Comment thread docs/html/errors.md
# Error Index

Inspired by the [Rust Compiler Error Index], this page describes the various
errors that may be presented by `sphinx-theme-builder`, indicating known causes
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.

Suggested change
errors that may be presented by `sphinx-theme-builder`, indicating known causes
errors that may be presented by `pip`, indicating known causes

Comment thread docs/html/errors.md
Comment on lines +13 to +19
## Pip Errors

Generic pip errors do not contain links to this page.

## Diagnostic Pip Errors

Diagnositic pip errors contain links to this page.
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.

We can drop these. 😅

Comment thread docs/html/errors.md

**What you can do:**

There are three standard ways to resolve this, depending on your goal: First, use a Virtual Environment. Second, use pipx if you want to install a tool for use from the command line. Lastly, if you absolutely must install a package system-wide and understand the risks of breaking your OS, then you can bypass the check by adding the specific flag: `--break-system-packages` to the pip install command.
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.

Let's make this a bullet list.

Comment thread docs/html/errors.md

When pip cannot find a wheel file for a dependency, pip tries to build the wheel from the source. If building the wheel from source fails, this error is raised.

**What you can do:**
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.

nit: Add newline after, for consistency -- here, and elsewhere.

Comment thread news/10421.doc.rst
@@ -0,0 +1 @@
Adding a details_link to the DiagnosticPipError to link to the relevant documentation for the error.
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.

Suggested change
Adding a details_link to the DiagnosticPipError to link to the relevant documentation for the error.
Adding a link to user-facing guidance in documentation for certain error messages.

Comment thread docs/html/errors.md

**What you can do:**

Clear the pip cache `pip cache purge` and then upgrade pip `pip install --upgrade pip`. Then find the path to the site-packages `python -m site` and look for folders with invalid names such as folders with `~` and delete them.
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.

Suggested change
Clear the pip cache `pip cache purge` and then upgrade pip `pip install --upgrade pip`. Then find the path to the site-packages `python -m site` and look for folders with invalid names such as folders with `~` and delete them.
Clear the pip cache (`pip cache purge`) and then upgrade pip (`pip install --upgrade pip`). Then find the path to the site-packages `python -m site` and delete folders with invalid names such as folders with `~`.

Comment thread docs/html/errors.md
Comment on lines +81 to +83
Incorrect: requires = "setuptools"
Correct: requires = ["setuptools", "wheel"]

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.

Suggested change
Incorrect: requires = "setuptools"
Correct: requires = ["setuptools", "wheel"]
Incorrect: `requires = "setuptools"`
Correct: `requires = ["setuptools", "wheel"]`

Comment thread docs/html/errors.md

Add the following block or equivalent to your pyproject.toml file. This tells pip to use setuptools as the default build tool:

```
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.

Suggested change
```
```toml

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.

Add additional diagnostics to our error messages

2 participants