Load environment variables script only when executing tasks. #3550
Replies: 5 comments
-
I think we could have a |
Beta Was this translation helpful? Give feedback.
-
Sourcing the script (and running a bash subprocess, etc) every time there's a new shell prompt does seem a little bit much, though technically it's the only way to be entirely correct. Direnv just runs its stuff on entry to the environment and honestly that seems good for 99% of cases. Checking for modifications on the script being sourced would get you to 99.9% I think? |
Beta Was this translation helpful? Give feedback.
-
As you said sourcing the script every time is the only way to be 100% correct. Something simple like The use case I have is setting up environment variables for a heavily parallelised build process. I could source the file before running the tasks but I would prefer to keep it consistent with having mise as the entrypoint. I like the idea of |
Beta Was this translation helpful? Give feedback.
-
FYI there does seem to currently be a bug in "short-circuiting" logic that prevents running scripts if nothing has been changed: #1617 |
Beta Was this translation helpful? Give feedback.
-
I'm a little curious how this behaves now with the hooks changes in, this may be solved now. If not, a hacky solution would be a hook on enter which just calls |
Beta Was this translation helpful? Give feedback.
-
We can currently set
_.env
to a shell script and read the exported variables into the mise environment.It would be nice to have a
_.env
scoped to tasks and only executed/templated when tasks are run. This would constant execution during regular shell usage.Beta Was this translation helpful? Give feedback.
All reactions