Skip to content
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

auto calling hook-env breaks zsh integration on new terminal session #3391

Closed
benvp opened this issue Dec 7, 2024 · 14 comments · Fixed by #3396
Closed

auto calling hook-env breaks zsh integration on new terminal session #3391

benvp opened this issue Dec 7, 2024 · 14 comments · Fixed by #3396
Labels

Comments

@benvp
Copy link

benvp commented Dec 7, 2024

Describe the bug
After the last update to v2024.12.1 mise is no longer working when starting a new terminal session. After running source ~/.zshrc it starts to work properly again. Same applies if I manually run eval $("mise hook-env").

To Reproduce
Create a .zshrc file with

eval "$(/usr/bin/mise activate zsh)"

Open a new shell, try to run any tool (e.g. node --version). The version of mise would not be used.

Expected behavior
It should work direclty when opening up a new session as it did in previous versions.

mise doctor output

version: 2024.12.1 linux-x64 (c364198 2024-12-06)
activated: yes
shims_on_path: no

build_info:
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Fri, 6 Dec 2024 12:41:43 +0000
  Rust Version: rustc 1.83.0 (90b35a623 2024-11-26)
  Profile: release

shell:
  /bin/zsh
  zsh 5.9 (x86_64-pc-linux-gnu)

dirs:
  cache: ~/.cache/mise
  config: ~/.config/mise
  data: ~/.local/share/mise
  shims: ~/.local/share/mise/shims
  state: ~/.local/state/mise

config_files:
  ~/.config/mise/config.toml

backends:
  aqua
  asdf
  cargo
  core
  gem
  go
  npm
  pipx
  spm
  ubi
  vfox

plugins:
  elixir  https://github.com/mise-plugins/mise-elixir.git#8efb115
  lua     https://github.com/Stratus3D/asdf-lua.git#e0c15ea

toolset:
  asdf:elixir@1.17.3-otp-27
  asdf:lua@5.4.7
  core:erlang@27.1
  core:node@16.20.2
  core:rust@1.72.0

env_vars:
  MISE_SHELL=zsh

settings:

No problems found

Additional context
IMO that's what broke it for me: #3373
I am running Arch Linux.

@benvp benvp added the bug label Dec 7, 2024
@benvp benvp changed the title auto calling hook-env partly breaks zsh integration auto calling hook-env breaks zsh integration on new terminal session Dec 7, 2024
@jdx
Copy link
Owner

jdx commented Dec 7, 2024

I can't seem to reproduce. Can you enable file trace logging so we can see what it's doing?

@benvp
Copy link
Author

benvp commented Dec 7, 2024

Thanks for the quick feedback. Here you go

mise.log

@jdx
Copy link
Owner

jdx commented Dec 7, 2024

I think there is something else that might be going on specific to node:

TRACE  1 [src/backend/mod.rs:246] node is not installed, path: ~/.local/share/mise/installs/node/lts (runtime symlink)

other than that it seems to be calling hook-env just fine. Do you have other tools in PATH?

@benvp
Copy link
Author

benvp commented Dec 7, 2024

I saw that, too. Interestingly mise install says that all runtimes are correctly installed. I also use other plugins like e..g elixir. Calling iex (the elixir shell) doesn't work until I manually re-source the ~/.zshrc or manually run hook-env.

Dunno if it helps, but using shims does work properly.

@jdx
Copy link
Owner

jdx commented Dec 7, 2024

you didn't answer my question, what's PATH when you start the shell? If other things are there this is something with node, and it appears to be that you're using lts as the version—which should function but I suspect it's something with version aliases that is not working correctly.

If you can confirm that is the case, I'll have more steps for you to figure out why node@lts isn't working right.

@jdx
Copy link
Owner

jdx commented Dec 7, 2024

I am suspicious that #3373 broke anything. All that should do is call hook-env one extra time. Have you tried downgrading?

Here's some other things to try:

  • mise x -- which node (without activating mise at all)
  • mise tool node
  • mise hook-env -s zsh (actually see what it's outputting, is PATH in there? note that it will do nothing if mise is already activated in the session)
  • eval "$(mise hook-env -s zsh)" (without activating mise first)

@benvp
Copy link
Author

benvp commented Dec 7, 2024

Sorry, that's the path immdiately after starting the shell

/home/benvp/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

And that's the output after re-sourcing ~/.zshrc

/home/benvp/.local/share/mise/installs/node/22.12.0/bin:/home/benvp/.cargo/bin:/home/benvp/.local/share/mise/installs/elixir/1.17.3-otp-27/bin:/home/benvp/.local/share/mise/installs/elixir/1.17.3-otp-27/.mix/escripts:/home/benvp/.local/share/mise/installs/erlang/27.1/bin:/home/benvp/.local/share/mise/installs/lua/5.4.7/bin:/home/benvp/.local/share/mise/installs/lua/5.4.7/luarocks/bin:/home/benvp/bin:/home/benvp/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

@jdx
Copy link
Owner

jdx commented Dec 7, 2024

sorry I read this again:

Same applies if I manually run eval $("mise hook-env").

given that, I really don't think #3373 can possibly have affected this, it didn't make any change to hook-env, only activate

@jdx
Copy link
Owner

jdx commented Dec 7, 2024

are you certain that ~/.zshrc is getting read and it's getting to the activation step?

@jdx
Copy link
Owner

jdx commented Dec 7, 2024

I wonder if possibly this is happening because mise isn't on PATH, or maybe you're doing something in ~/.zshrc that happens after mise is activated. Though with all of that I can find arguments why they wouldn't be an issue

@jdx
Copy link
Owner

jdx commented Dec 7, 2024

frankly with what you've told me and what I see in the logs I'm at a loss

@jdx
Copy link
Owner

jdx commented Dec 7, 2024

idk maybe try adding mise hook-env -s zsh --trace instead of activating and without the eval. See what it's doing and what it dumps out.

Beyond that, you could do this: mise activate zsh >> ~/.zshrc to output the actual content of the activation step. From there you can remove _hook_env which would confirm if #3373 is the culprit.

@benvp
Copy link
Author

benvp commented Dec 7, 2024

I think I found a way to reproduce it.

I have a ~/.zprofile containing the shims activation

eval "$(/usr/bin/mise activate zsh --shims)"

And the ~/.zshrc contained the normal activation.

eval "$(/usr/bin/mise activate zsh)"

As I understand from the latest readme, that shouldn't be an issue and the .zshrc content would overwrite the shims when using an interactive shell. However, at first it seem to break it (for me).

When I remove the activation from the .zshrc and then run the activation code in that session, it will first break mise. If I run that a second time, it starts working again.

Seems that the first run removes the shims from PATH and the second adds the actual paths to PATH.

image

@jdx
Copy link
Owner

jdx commented Dec 7, 2024

ah I see the problem. We run hook-env and then remove the shims directory from PATH without the tools. Then hook-env doesn't run again because of the early-exit logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants