Repository navigation
Restate available versions in error messages - #20809
notatallshaw wants to merge 6 commits into
Conversation
uv test inventory changesThis PR changes the tests when compared with the
|
b00477d to
bf48641
Compare
|
Force-pushed, so the commit sha linked from #20804 is stale ( |
bf48641 to
b3aa9dd
Compare
|
Now I have a better handle on this issue, implementing a similar approach in nab, I'm marking it as ready for review. If uv maintainers would like me to merge it into #20804 I can do that also, but I do think the two issues are fairly separately reviewable. |
| if narrowed == Range::full() { | ||
| return narrowed; | ||
| } |
There was a problem hiding this comment.
it'd be helpful to preserve singletons here no? Otherwise something like a==1.0 was yanked becomes all versions of 'a' were yanked which is less helpful
| ╰─▶ Because attrs==21.1.0 was yanked (reason: Installable but not importable on Python 3.4) and only the following versions of attrs are available: | ||
| attrs<=20.3.0 | ||
| attrs==21.1.0 | ||
| attrs>=21.2.0 | ||
| we can conclude that attrs>20.3.0,<21.2.0 cannot be used. | ||
| And because you require attrs>20.3.0,<21.2.0, we can conclude that your requirements are unsatisfiable. |
There was a problem hiding this comment.
tbh I find the formatting we have on main not more helpful either, maybe:
Because attrs==21.1.0 was yanked (...) and there are no other versions in range, we can conclude that attrs>20.3.0,<21.2.0 cannot be used.
CC @zanieb
There was a problem hiding this comment.
I've never learnt the art of reading uv error messages, and they're still on my to-do list for nab, so I have literally no opinion here, they all look the same to me now that they're not clobbering specific information like indexes.
There was a problem hiding this comment.
The idea is that we start with simple facts (e.g. a>=1,<2 depends on b>=1,<2 and that c>=2,<3 depends on b>=2,<3) to build the minimal case why requirements don't work. This usually tasks the shape of a DAG starting from (or ending in) root: root depends on a>=1,<2, so it also required b>=1,<2, and root depends on c>=2,<3, so b>=2,<3, and there are no version of b for that, so it's unfulfillable.
PubGrub's idea is to generate a prove for unfulfillability. We're treating each dependency as an implication (e.g. a>=1,<2 => b>=1,<2) and then chaining them (e.g. a>=1,<2 => b>=1,<2 and b>=1,<2 => c>=1,<2 implies a>=1,<2 => c>=1,<2) until reach that root (your dependencies) implies false. This prove only contains the packages and versions that are actually involved in the problem, so you know where to tweak. Through this prove we surface reasons why your resolution might be failing, such as the yanked version in the example above or a requires-python that is wider than that of your dependencies.
There's two ways to present those proves: Start from the root and chain yourself to leaves, or start from the leaves and build your case against root. uv does the latter.
The tricky parts are granularity and ordering: If we say that there are only incompatible wheels, should we list all the versions, or only the range that contains all the versions? Which implication do we want to highlight, what is the bound that the user wants to change, override or report upstream?
There was a problem hiding this comment.
astral-sh#566 addresses this but is a bit niche.
I have been iterating on the resolver errors in a stack over there.
There was a problem hiding this comment.
As long as we're not losing information here or otherwise clearly regressing, we can address simplifying them separately
a30250e to
64ecb36
Compare
|
Merged this back into #20804 as it seems clear the resulting changing need to be reviewed as one unit (and there's no helpful stacking UI for contributing to an external repo). |
This is a partial port of a technique I am adopting in nab, I have been following @konstin's lead in astral-sh/pubgrub#75 and extending the approach into more places (notatallshaw/nab#357, notatallshaw/nab#590, notatallshaw/nab#592, notatallshaw/nab#604). This speeds up `uv lock` with `requires-python >= 3.8` over boto3 + awscli by ~20% wall time, and the largest accumulated range in the run drops from 287 segments to 2. `add_unavailable_version` records one singleton incompatibility per rejected version, so consecutive rejections never coalesce and the accumulated range grows a hole per version. This widens each singleton to the gap between its neighbors in the known versions, the same interval decided-version dependencies use. The win needs long runs of rejected versions. The main source is a Python floor below the ecosystem's support boundary: boto3 and awscli dropped 3.8 in April 2025 and now require >= 3.10, so a 3.8 floor rejects hundreds of releases in one run, while a 3.10 floor rejects almost nothing (14 rounds, 2 segments either way) and the change is a no-op. The first commit keys the pre-release hint on the requesting requirement instead of the derived set's bounds: widened bounds land on whatever the registry lists next, and a pre-release neighbor used to read as a pre-release marker nobody wrote. Rejection widening makes that routine, so the fix leads the series. The second commit merges unavailable versions that are causes of the same derivation, and the third is the widening itself. The fourth keeps the subsequent-index hint, which was suppressed whenever the set covered all versions; after widening that also covers "the index listed versions and none of them worked", which is the case the hint is for. The last two commits are #20809, merged in here so the error messages land as one change. With the widening, uv no longer asks for a version in a gap it created, so the `no_versions` incompatibility behind "only the following versions of X are available" is no longer created there, and steps that cross a gap stop following from the premises next to them. The fifth commit adds that clause back while the tree is reduced, on whichever cause rules the package out, or on the step itself when neither does. The sixth reports the one version a package has as that version rather than as a range over it, so a rejected `sphinx 7.2.6` reads `sphinx==7.2.6` and not `sphinx>=7.2.6`. Neither touches the solver. <details> <summary>MRE</summary> ```toml [project] name = "mre" version = "0.1.0" requires-python = ">=3.8" dependencies = ["boto3", "awscli"] ``` Max accumulated segments (287 on main, 2 with this PR; `uv.lock` identical): ```console $ uv lock --exclude-newer 2026-07-01 -v 2>&1 | grep 'Searching for a compatible version' | awk -F'|' '{print NF}' | sort -n | tail -1 ``` Wall (run without `-v`, which prints the accumulated ranges and dominates the time): ```console $ hyperfine --warmup 3 --min-runs 20 --prepare 'rm -f uv.lock' 'uv lock --exclude-newer 2026-07-01' ``` </details>
Stacked on #20804, only the last commit is new.
With the widening, uv no longer asks for a version in a gap it created, so the
no_versionsincompatibility behind "only the following versions of X are available" is no longer created there. Steps that cross a gap then stop following from the premises next to them.This adds the clause back while the tree is reduced: a step that reaches past what its causes report gets a
NoVersionscause for the difference, on whichever cause rules the package out, or on the step itself when neither does. No solver change.It also clamps a requires-python rejection to the listing. That rejection is recorded as a dependency on Python, so its widened range kept an unbounded end and the message named a range instead of the version,
sphinx>=7.2.6where main sayssphinx==7.2.6, in the hint as well. A range likesphinx>=7.2.6reads as a claim about every later release when only one version was rejected.