mirror of
https://github.com/apple/pkl.git
synced 2026-01-13 15:13:38 +01:00
Poor typecheck error message when using absolute package import for project dependency #366
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @StefMa on GitHub (Nov 12, 2025).
[bioball] When using an absolute package import in place of a project import, Pkl eval will fail (expected). However, the error message thrown by Pkl is quite poor.
Original issue:
Given
PklProject:index.pkl:ver/test.pkl:When-Then
If I run
pkl eval index.pklthen I get the following errorPossible solution
Use the same import statement in both files!
Either use
@gha/orpackage://in index.pkl andver/test.pklObservation
Even though the import is the same,
pkldoesn't know that it is "valid".One pkl file uses the dependency notion (defined in
PklProject), while the other uses the package import.Expectation
I would expect that
pklcan detect that using the@ghaimport is equal to thepackage://import (for the same package obviously) and therefore don't error in such a import mix case.Feel free to change the title of this issue.
I've no idea how to call this 🫣
@bioball commented on GitHub (Nov 12, 2025):
This is expected; a project dependency is a different package than what you get with absolute package imports. If you're using dependencies, you cannot use
import "package//:..."to satisfy the same types.However, our error message is kind of bad here. I'm re-purposing your issue to be about the error message.
@StefMa commented on GitHub (Nov 12, 2025):
But... 🤨 Why is it different?
It is the same, right? So why are the types different?
Coming from outside, it looks like using a dependency notion is just like a "typealias".
So I would expect that it work.
Also given your argument that "all" package:// import are different types, at least this is how I understand it, is not true. Because if I use it in both files, pkl detect that it is the same and it evaluate just fine...
@bioball commented on GitHub (Nov 12, 2025):
They're different because they resolve their own dependencies differently. A
package://import will resolve its dependencies according to its own manifest, whereas a dependency notation import will resolve dependencies according to thePklProject.deps.jsonfile. Because of these, they can't be the same type.By the way, a dependency notation import has scheme
projectpackage://underneath the hood, so they have different URIs!@StefMa commented on GitHub (Nov 13, 2025):
🤯
I chatted with AI a bit about this and it seems
pkldistringuesh between the imports.So even if using the "same package", as soon as the import "looks" different (
projectpackage(dependency notion),package(direct import),https(direct http import)), the types will never be the same. Correct?So an
httpimport of an pkl file that haspackage://stefma.github.acitonswill not be compatible with the direct import or PklProject import within the project.Understood. Thanks!
Indeed, a better error message should be thrown!
And btw:
The intellij plugin also doesn't recognize this error!
It isn't highlighed as an error.
test.Actionshould be highlighted as "not compatible`.@bioball commented on GitHub (Nov 13, 2025):
Yeah, agreed, that's an incorrect typecheck in pkl-intellij. Can you file an issue in apple/pkl-intellij? And likely we need to fix this for apple/pkl-lsp too.