Triple dot module uri resolution for local dependencies #117

Open
opened 2025-12-30 01:21:04 +01:00 by adam · 2 comments
Owner

Originally created by @jw-y on GitHub (Mar 15, 2024).

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

Originally created by @jw-y on GitHub (Mar 15, 2024). 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
adam added the bug label 2025-12-30 01:21:04 +01:00
Author
Owner

@bioball commented on GitHub (Mar 16, 2024):

Thanks! Looks like a bug.

@bioball commented on GitHub (Mar 16, 2024): Thanks! Looks like a bug.
Author
Owner

@juhagman commented on GitHub (Apr 29, 2025):

I cannot reproduce. Latest Pkl, latest macOS.

>> tree
.
├── base
│   ├── bar
│   │   └── baz
│   │       └── bar.pkl
│   ├── foo.pkl
│   └── PklProject
└── derive
    ├── Pklproject
    └── tmp.pkl

5 directories, 5 files

>> cd derive

>> pkl project resolve
/Users/jhagman/tests/pklproject/derive/PklProject.deps.json

>> pkl eval tmp.pkl
foo {
  var = "Hi"
}

>> pkl --version
Pkl 0.28.1 (macOS 15.2, native)

>> uname -a
Darwin FSA-X1CDGYJQ7G 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:39 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6020 arm64
@juhagman commented on GitHub (Apr 29, 2025): I cannot reproduce. Latest Pkl, latest macOS. ``` >> tree . ├── base │   ├── bar │   │   └── baz │   │   └── bar.pkl │   ├── foo.pkl │   └── PklProject └── derive ├── Pklproject └── tmp.pkl 5 directories, 5 files >> cd derive >> pkl project resolve /Users/jhagman/tests/pklproject/derive/PklProject.deps.json >> pkl eval tmp.pkl foo { var = "Hi" } >> pkl --version Pkl 0.28.1 (macOS 15.2, native) >> uname -a Darwin FSA-X1CDGYJQ7G 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:39 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6020 arm64 ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#117