Triple dot module uri resolution for local dependencies
- Dominant language
- Java
- Stars
- 11.5k
- Forks
- 402
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 20
Description
Not sure if I am doing something wrong, but here it goes.
Here is the file structure
```
base
| - foo.pkl
| - PklProject
| - bar
| - baz
| - bar.pkl
derive
| - tmp.pkl
| - PklProject
```
# Summary
Basically, if it try to import and initialize with `import "@base/bar/baz/bar.pkl"` in `derive/tmp.pkl`
where `base/bar/baz/bar.pkl` imports `base/foo.pkl` with triple dot syntax (`extends ".../foo.pkl"`)
it gives following error
```
–– Pkl Error ––
I/O error loading module `projectpackage://github.com/pkl@0.1.0#/bar/foo.pkl`.
NoSuchFileException: /home/jwyang/test_pkl/derive/../base/bar/foo.pkl
3 | foo = new bar{}
^^^
at tmp#foo (file:///home/jwyang/test_pkl/derive/tmp.pkl, line 3)
106 | text = renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (https://github.com/apple/pkl/blob/0.25.2/stdlib/base.pkl#L106)
```
# Files
## `base/PklProject`
```
amends "pkl:Project"
local github_path = "github.com"
package = new {
name= "foo"
baseUri="package://\(github_path)/pkl"
version= "0.1.0"
packageZipUrl="https://\(github_path)/"
exclude {
"tests"
"tests/**"
}
}
```
## `base/foo.pkl`
```
abstract module foo
var = "Hi"
```
## `base/bar/baz/bar.pkl`
```
module bar
extends ".../foo.pkl"
```
## `derive/PklProject`
```
amends "pkl:Project"
dependencies {
["base"]= import(".../base/PklProject")
}
```
## `derive/tmp.pkl`
```
import "@base/bar/baz/bar.pkl"
foo = new bar{}
```
## Commands
```
cd derive
pkl project resolve
pkl eval tmp.pkl # this throws above error
```
## Resulting `PklProject.deps.json`
```
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://github.com/pkl@0": {
"type": "local",
"uri": "projectpackage://github.com/pkl@0.1.0",
"path": "../base"
}
}
}
```
If I replace triple dot syntax in `base/bar/baz/bar.pkl` with `extends "../../foo.pkl"`
error doesn't show anymore
Contributor guide
Research direction
Reproduce the issue with `pkl project resolve` and `pkl eval tmp.pkl` from `derive`, using `base/bar/baz/bar.pkl` and `derive/tmp.pkl`. Investigate triple-dot resolution from the imported module and compare it with the working `../../foo.pkl` form. Done means `@base/bar/baz/bar.pkl` resolves `base/foo.pkl` without the reported `NoSuchFileException`.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100