Skip to content

Commit 119c49f

Browse files
authored
Add backtracking scenarios with missing packages (#298)
Closes astral-sh/uv#1250
1 parent 65c2c47 commit 119c49f

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name = "backtrack-to-missing-package"
2+
description = """There are two packages, `a` and `b`. All versions of `b` require a specific
3+
version of `a`, but that version requires a package `c` that does not exist. The resolver
4+
must backtrack through all versions of `b` and eventually fail because no solution exists."""
5+
6+
[expected]
7+
satisfiable = false
8+
9+
[root]
10+
requires = ["a", "b"]
11+
12+
[packages.a.versions]
13+
# This version works but is incompatible with all versions of b
14+
"2.0.0" = {}
15+
# This version is required by b but depends on a missing package
16+
"1.0.0" = { requires = ["c"] }
17+
18+
[packages.b.versions]
19+
"1.0.0" = { requires = ["a==1.0.0"] }
20+
"2.0.0" = { requires = ["a==1.0.0"] }
21+
"3.0.0" = { requires = ["a==1.0.0"] }
22+
23+
# Note: package `c` is intentionally not defined (missing package)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name = "backtrack-with-missing-package"
2+
description = """There are two packages, `a` and `b`. The latest version of `b` requires
3+
a specific version of `a`. The older version of `b` requires a package `c` that does not
4+
exist. The resolver should backtrack on `a` (not `b`) to find a solution without needing
5+
to try `b==1.0.0` which would fail due to the missing package."""
6+
7+
[expected]
8+
satisfiable = true
9+
10+
[expected.packages]
11+
a = "1.0.0"
12+
b = "2.0.0"
13+
14+
[root]
15+
requires = ["a", "b"]
16+
17+
[packages.a.versions]
18+
"1.0.0" = {}
19+
"2.0.0" = {}
20+
21+
[packages.b.versions]
22+
# Old version requires a missing package - resolver should not need this
23+
"1.0.0" = { requires = ["c"] }
24+
# New version requires specific a version - should work with backtracking
25+
"2.0.0" = { requires = ["a==1.0.0"] }
26+
27+
# Note: package `c` is intentionally not defined (missing package)

0 commit comments

Comments
 (0)