Originally created by @discount-elf on GitHub (Apr 26, 2025).
It would be useful to be able to do the following:
pkl project package -p 'version=1.0.1'
PklProject
package {
name = "somepkg"
baseUri = "package://example.com/pkl/\(name)/\(name)"
version = read("prop:version")
packageZipUrl = "https://example.com/pkl/\(name)/\(name)@\(version).zip"
}
Currently pkl 0.28.1 complains about the prop module reader not being present. I couldn't get it working tweaking any combination of --allowed-resources and --allowed-modules
Originally created by @discount-elf on GitHub (Apr 26, 2025).
It would be useful to be able to do the following:
`pkl project package -p 'version=1.0.1'`
PklProject
```pkl
package {
name = "somepkg"
baseUri = "package://example.com/pkl/\(name)/\(name)"
version = read("prop:version")
packageZipUrl = "https://example.com/pkl/\(name)/\(name)@\(version).zip"
}
```
Currently pkl `0.28.1` complains about the prop module reader not being present. I couldn't get it working tweaking any combination of `--allowed-resources` and `--allowed-modules`
We don't allow external properties when loading PklProject because that module is somewhat special; it's a manifest that controls Pkl evaluation in a normal program. E.g. through evaluatorSettings:
When you eval another module, the PklProject first gets evaluated, and any settings therein are applied to the rest of the evaluation. We want external properties to specifically be an input to a "normal" program.
If you want to set the version from an external source, you have two choices:
Read environment variables (e.g. version = read("env:VERSION"))
Read a file (e.g. version = read("VERSION.txt").text.trim())
I'd recommend the second approach, because this allows IDEs to run the sync projects action.
@bioball commented on GitHub (May 7, 2025):
We don't allow external properties when loading `PklProject` because that module is somewhat special; it's a manifest that _controls_ Pkl evaluation in a normal program. E.g. through `evaluatorSettings`:
```pkl
amends "pkl:Project"
evaluatorSettings {
externalProperties {
["foo"] = "bar"
}
}
```
When you eval another module, the `PklProject` first gets evaluated, and any settings therein are applied to the rest of the evaluation. We want external properties to specifically be an input to a "normal" program.
If you want to set the version from an external source, you have two choices:
1. Read environment variables (e.g. `version = read("env:VERSION")`)
2. Read a file (e.g. `version = read("VERSION.txt").text.trim()`)
I'd recommend the second approach, because this allows IDEs to run the sync projects action.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @discount-elf on GitHub (Apr 26, 2025).
It would be useful to be able to do the following:
pkl project package -p 'version=1.0.1'PklProject
Currently pkl
0.28.1complains about the prop module reader not being present. I couldn't get it working tweaking any combination of--allowed-resourcesand--allowed-modules@bioball commented on GitHub (May 7, 2025):
We don't allow external properties when loading
PklProjectbecause that module is somewhat special; it's a manifest that controls Pkl evaluation in a normal program. E.g. throughevaluatorSettings:When you eval another module, the
PklProjectfirst gets evaluated, and any settings therein are applied to the rest of the evaluation. We want external properties to specifically be an input to a "normal" program.If you want to set the version from an external source, you have two choices:
version = read("env:VERSION"))version = read("VERSION.txt").text.trim())I'd recommend the second approach, because this allows IDEs to run the sync projects action.
@discount-elf commented on GitHub (May 7, 2025):
Ah got it. Yes I was using the second approach before filing! Thank you!