jdx / mise

dev tools, env vars, task runner
https://mise.jdx.dev
MIT License
8.28k stars 219 forks source link

mise activate doesn't take effect immediately #2170

Closed radiosilence closed 1 month ago

radiosilence commented 1 month ago

So I'm trying to figure out why the ruby-lsp extension for vscode is not working despite me running an command of eval "$(mise activate zsh) in it's config, so I broke out into a "naked" bash shell (IE with nothing configured) to see exactly what was happening.

$ ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin23]
$ eval "$(mise activate bash)" && ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin23]
$ eval "$(mise activate bash)" && ruby -v
ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-darwin23]

So we an see that the command works, but only after the second invocation - IE I am guess that due to using precmd hooks, it wont have added them to the first invocation because it was already executing a command.

I guess this is just a function of how it's implemented and we should use shims for this sort of thing?

jdx commented 1 month ago

please read my blog post on the topic to understand why this is the case: https://jdx.dev/posts/2024-04-13-shims-how-they-work-in-mise-en-place/

tl;dr: this is expected behavior and there is no way to "fix" it

radiosilence commented 1 month ago

Makes sense, thanks for confirming. I'd ended up using that approach anyway 😀

Love mise, keep up the good work!