-
Notifications
You must be signed in to change notification settings - Fork 361
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
Lazily evaluated env template variables in path entries #1912
Comments
@jdx here's a demo of my current branch, which allows lazy path entries to be specified using
[env]
GEM_HOME = "{{env.HOME}}/.gem"
_.path = [
{ value = "{{env.GEM_HOME}}/bin" },
]
[env]
GEM_HOME = "{{env.HOME}}/.mise-gemsets/foo" ~% mise env
export GEM_HOME=/Users/josb/.gem
export PATH='/Users/josb/.gem/bin:/opt/homebrew/opt/ruby/bin:...
~% cd ~/github/josb
~/github/josb% mise env
export GEM_HOME=/Users/josb/.mise-gemsets/foo
export PATH='/Users/josb/.mise-gemsets/foo/bin:/opt/homebrew/opt/ruby/bin:...
~/github/josb% Normal Feedback welcome. |
there's another ticket (didn't have time to search for it) where we've talked about being able to configure some env vars to be parsed after tools are loaded that I think would be a prerequisite for doing this |
Do you mean #1982? That seems to not concern env var evaluation in |
Oh sorry, I thought you wanted it to run after the tools are loaded, this makes sense |
I seem to not be able to view your branch, not sure if that's because I'm on my phone |
Hm. I'll open a PR in your repo later today so you take a look. |
oh it works on my computer, go ahead and submit a PR—first glance it looks solid 👍 |
Thank you, @jdx! Much appreciated. 🙏 |
Setup:
HOME=/Users/john
config.toml
file with:_.path
template entry with value"{{env.GEM_HOME}}/bin"
GEM_HOME = "{{env.HOME}}/.gem"
.mise.toml
file in some directory under the home directory with:GEM_HOME = "{{env.HOME}}/.mise-gemsets/foo"
Today, env entries in path templates are expanded using the environment variables defined in the same mise config file, either global or local.
The idea behind a lazily expanded reference in path entries is to only expand the path env reference after both the global and local mise configs have been read, and use whatever value the env variable has at that point.
In the above example, this would mean that in the specific directory a path entry valued
/Users/john/.mise-gemsets/foo/bin
would be added, whereas elsewhere the entry/Users/john/.gem/bin
would be added instead.Today this doesn't work because the path entry has to be set in the global config where it is always added with the global value, which is not what we want here.
If there's another way to achieve this with existing mise facilities I'd love to learn about it. Thanks!
The text was updated successfully, but these errors were encountered: