3

I'm having trouble loading the correct version of ruby/node when I create a tmux session. This doesn't happen if I use ruby/node without tmux

$ tmux new-session -s servers
$ which ruby
/usr/bin/ruby

Compared to normal terminal session:

/Users/amree/.asdf/shims/ruby

Related dotfiles:

More information

  • It's running the same shell (with and without tmux). I confirmed it by running echo $SHELL
  • Commenting out the whole tmux config file doesn't help
Stratus3D
  • 4,648
  • 4
  • 35
  • 67
Amree
  • 2,890
  • 3
  • 30
  • 51
  • Is `tmux` loading up `bash` or `zsh`? Is there a different shell being loaded when you open the terminal vs tmux? – alpha_989 Feb 26 '18 at 03:56
  • Also what happens if you load up `tmux` without any config (by moving the tmux.conf and associated files) out of the tmux load path? – alpha_989 Feb 26 '18 at 03:57
  • `tmux` is loading `zsh`. Confirmed by running `echo $SHELL` and based on its look. This is the same shell that run without `tmux` – Amree Feb 26 '18 at 03:59
  • @alpha_989 I commented out everything in `.tmux.conf` and it's still loading `zsh` and the problem still persists (not loading the correct ruby or node version correctly) – Amree Feb 26 '18 at 04:01

1 Answers1

4

The actual problem was because of the $PATH has been prepended automatically by /etc/zprofile again when I opened the tmux session.

In order to prevent that, I just disable it when it's in tmux session:

# /etc/zprofile
# system-wide environment settings for zsh(1)
if [ -x /usr/libexec/path_helper ]; then
  if [ -z "$TMUX" ]; then
    eval `/usr/libexec/path_helper -s`
  fi
fi
Amree
  • 2,890
  • 3
  • 30
  • 51
  • Mac 13.2+ doesn't seem to allow editing /etc/zprofile as it is read-only protected, is there another way to solve this? – Amozoss Apr 20 '23 at 16:01