Skip to content

Commit 4bce1a3

Browse files
authored
Fix bug in terms when collapsing unavailable versions in resolver errors (#9877)
Closes #9861 Closes pubgrub-rs/pubgrub#297
1 parent b2459e6 commit 4bce1a3

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

crates/uv-resolver/src/error.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,18 @@ fn collapse_unavailable_versions(
673673
// And the package and reason are the same...
674674
if package == other_package && reason == other_reason {
675675
// Collapse both into a new node, with a union of their ranges
676+
let versions = other_versions.union(versions);
677+
let mut terms = terms.clone();
678+
if let Some(Term::Positive(range)) = terms.get_mut(package) {
679+
*range = versions.clone();
680+
}
676681
*tree = DerivationTree::Derived(Derived {
677-
terms: terms.clone(),
682+
terms,
678683
shared_id: *shared_id,
679684
cause1: cause1.clone(),
680685
cause2: Arc::new(DerivationTree::External(External::Custom(
681686
package.clone(),
682-
versions.union(other_versions),
687+
versions,
683688
reason.clone(),
684689
))),
685690
});
@@ -696,12 +701,17 @@ fn collapse_unavailable_versions(
696701
// And the package and reason are the same...
697702
if package == other_package && reason == other_reason {
698703
// Collapse both into a new node, with a union of their ranges
704+
let versions = other_versions.union(versions);
705+
let mut terms = terms.clone();
706+
if let Some(Term::Positive(range)) = terms.get_mut(package) {
707+
*range = versions.clone();
708+
}
699709
*tree = DerivationTree::Derived(Derived {
700-
terms: terms.clone(),
710+
terms,
701711
shared_id: *shared_id,
702712
cause1: Arc::new(DerivationTree::External(External::Custom(
703713
package.clone(),
704-
versions.union(other_versions),
714+
versions,
705715
reason.clone(),
706716
))),
707717
cause2: cause2.clone(),

crates/uv/tests/it/cache_prune.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ fn prune_unzipped() -> Result<()> {
263263
and all of:
264264
iniconfig<=0.1
265265
iniconfig>=1.0.0
266-
need to be downloaded from a registry, we can conclude that iniconfig<1.0.0 cannot be used.
266+
need to be downloaded from a registry, we can conclude that all of:
267+
iniconfig<=0.1
268+
iniconfig>=1.0.0
269+
cannot be used.
267270
And because you require iniconfig, we can conclude that your requirements are unsatisfiable.
268271
269272
hint: Pre-releases are available for `iniconfig` in the requested range (e.g., 0.2.dev0), but pre-releases weren't enabled (try: `--prerelease=allow`)

crates/uv/tests/it/pip_compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13818,7 +13818,7 @@ fn invalid_platform() -> Result<()> {
1381813818
open3d==0.16.1
1381913819
open3d==0.17.0
1382013820
open3d==0.18.0
13821-
and open3d<=0.15.2 has no wheels with a matching Python ABI tag, we can conclude that open3d<0.9.0.0 cannot be used.
13821+
and open3d<=0.15.2 has no wheels with a matching Python ABI tag, we can conclude that open3d<=0.15.2 cannot be used.
1382213822
And because open3d>=0.16.0 has no wheels with a matching platform tag and you require open3d, we can conclude that your requirements are unsatisfiable.
1382313823
"###);
1382413824

crates/uv/tests/it/pip_install.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2182,11 +2182,11 @@ fn install_only_binary_all_and_no_binary_all() {
21822182
anyio>=3.7.0,<=3.7.1
21832183
anyio>=4.0.0
21842184
have no usable wheels and building from source is disabled, we can conclude that all of:
2185-
anyio<1.1.0
2186-
anyio>1.4.0,<2.0.0
2187-
anyio>2.2.0,<3.0.0
2188-
anyio>3.6.2,<3.7.0
2189-
anyio>3.7.1,<4.0.0
2185+
anyio>=1.0.0,<=1.4.0
2186+
anyio>=2.0.0,<=2.2.0
2187+
anyio>=3.0.0,<=3.6.2
2188+
anyio>=3.7.0,<=3.7.1
2189+
anyio>=4.0.0
21902190
cannot be used.
21912191
And because you require anyio, we can conclude that your requirements are unsatisfiable.
21922192

crates/uv/tests/it/tool_list.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ fn tool_list_show_version_specifiers() {
276276

277277
uv_snapshot!(context.filters(), context.tool_list().arg("--show-version-specifiers")
278278
.env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str())
279-
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str()), @r#"
279+
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str()), @r###"
280280
success: true
281281
exit_code: 0
282282
----- stdout -----
@@ -287,12 +287,12 @@ fn tool_list_show_version_specifiers() {
287287
- flask
288288
289289
----- stderr -----
290-
"#);
290+
"###);
291291

292292
// with paths
293293
uv_snapshot!(context.filters(), context.tool_list().arg("--show-version-specifiers").arg("--show-paths")
294294
.env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str())
295-
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str()), @r#"
295+
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str()), @r###"
296296
success: true
297297
exit_code: 0
298298
----- stdout -----
@@ -303,5 +303,5 @@ fn tool_list_show_version_specifiers() {
303303
- flask ([TEMP_DIR]/bin/flask)
304304
305305
----- stderr -----
306-
"#);
306+
"###);
307307
}

0 commit comments

Comments
 (0)