Ensure local dependency matches PklProject.dep.json version (#1594)

The version of local project dependencies should _always_ exactly match
up with what's declared in a PklProject.deps.json; any package in the
transitive dependency tree should always be delcaring the same import
too.

Closes #1591
This commit is contained in:
Daniel Chao
2026-05-15 11:48:57 -07:00
committed by GitHub
parent 2fe565a0f2
commit 3ad1cb3645
9 changed files with 56 additions and 7 deletions
@@ -0,0 +1,7 @@
amends "pkl:Project"
dependencies {
// version declared in PklProject.deps.json does not line up with what this local dependency
// tells us its version is
["project6"] = import("../project6/PklProject")
}
@@ -0,0 +1,10 @@
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/project6@1": {
"type": "local",
"uri": "projectpackage://localhost:0/project6@1.5.0",
"path": "../project6/"
}
}
}
@@ -0,0 +1,3 @@
import "@project6/children.pkl"
res = children
@@ -20,9 +20,9 @@
"uri": "projectpackage://localhost:0/project2@1.0.0",
"path": "../project2/"
},
"package://localhost:12110/project6@1": {
"package://localhost:0/project6@1": {
"type": "local",
"uri": "projectpackage://localhost:12110/project6@1.0.0",
"uri": "projectpackage://localhost:0/project6@1.0.0",
"path": "../project6/"
},
"package://localhost:0/badImportsWithinPackage@1": {
@@ -20,9 +20,9 @@
"uri": "projectpackage://localhost:0/project2@1.0.0",
"path": "../project2/"
},
"package://localhost:12110/project6@1": {
"package://localhost:0/project6@1": {
"type": "local",
"uri": "projectpackage://localhost:12110/project6@1.0.0",
"uri": "projectpackage://localhost:0/project6@1.0.0",
"path": "../project6/"
},
"package://localhost:0/badImportsWithinPackage@1": {
@@ -2,7 +2,7 @@ amends "pkl:Project"
package {
name = "project6"
baseUri = "package://localhost:12110/project6"
baseUri = "package://localhost:0/project6"
version = "1.0.0"
packageZipUrl = "https://localhost:12110/project6/project6-\(version).zip"
packageZipUrl = "https://localhost:0/project6/project6-\(version).zip"
}
@@ -0,0 +1,11 @@
–– Pkl Error ––
Project `file:///$snippetsDir/input/projects/badProjectDeps7/PklProject` declares a dependency on a local package whose version doesn't match what is declared in `PklProject.deps.json`.
Declared: `package://localhost:0/project6@1.0.0`
Resolved: `package://localhost:0/project6@1.5.0`
Run `pkl project resolve` to update resolved dependencies.
x | import "@project6/children.pkl"
^^^^^^^^^^^^^^^^^^^^^^^^
at bug (file:///$snippetsDir/input/projects/badProjectDeps7/bug.pkl)