mirror of
https://github.com/apple/pkl.git
synced 2026-01-13 15:13:38 +01:00
Can't read env: resource on Windows
#310
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 @z-jxy on GitHub (May 24, 2025).
Version:
Pkl 0.28.2 (Windows 10.0, native)Pkl fails to find the
env:resource on Windows@bioball commented on GitHub (Jul 29, 2025):
This error is telling you that the
PATHenv var is not set.You can see all the env vars that are available with a globbed read, e.g.
read*("env:**").If you want to handle the case where the path is not set, you can do
read?("env:PATH"), which gives you a nullable value.@z-jxy commented on GitHub (Jul 29, 2025):
Didn't know this was possible, thanks for this!
I worded this issue poorly, my problem was that it's not finding the
PATHenvironment variable specifically.After updating the file to use
read*("env:**"), I realized the reason it doesn't work is because its mapped toenv:Pathwhen I was expectingenv:PATH. (environment variables are case-insensitive on Windows)This behavior is technically correct because the variable is
Pathcanonically, but this causes my file to be platform dependent (unless there's a way around this that I'm not aware of).Ideally, I would want
read("env:PATH")to work on both Linux and Windows, but I don't think it would make sense to support this:env:Pathandenv:PATHor justenv:PATH(maybe there's another way?)env:PATH,env:Pathwould no longer work, when it shouldI think a better solution would be if Pkl provided a way to access common environment variables across supported platforms (i.e., PATH, HOME, OS). Maybe this could be moved to a discussion? I think there are good uses cases for this
@bioball commented on GitHub (Jul 29, 2025):
Hm, that's worth thinking about. Pkl already has the
pkl:platformstdlib module, which provides many details, by the way.You can implement a platform-specific read like so:
Feel free to create a new discussion about extending the
Platformclass.@z-jxy commented on GitHub (Jul 29, 2025):
Ahh I didn't know about the platform module. That solves my issue. Thanks again!