Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triple dot module uri resolution for local dependencies #323

Open
jw-y opened this issue Mar 15, 2024 · 1 comment
Open

Triple dot module uri resolution for local dependencies #323

jw-y opened this issue Mar 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jw-y
Copy link
Contributor

jw-y commented 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

@bioball
Copy link
Contributor

bioball commented Mar 15, 2024

Thanks! Looks like a bug.

@holzensp holzensp added the bug Something isn't working label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants