Fix asdf $PATH loading in tmux on fish shell
OCT 2, 2025 • 2 MIN. READ •
Recently, I've been working on upgrading my React Native from 0.75.5 to the new architecture 0.81.1
and I had to upgrade my ruby version to 3. I've used nvm a lot before,
thus I tried rvm, but for some reason the gpg keys installation step got stuck.
So I decided to go with asdf instead, and it worked.
# Install asdf using brew
brew install asdf
# Install fish-asdf so that asdf works in fish shell
fisher install rstacruz/fish-asdf
# Add ruby plugin
asdf plugin add ruby
# Install latest ruby version
asdf install ruby latest
# Set global ruby version
asdf set --home ruby latest
# Set asdf shims path
asdf shims
# Check ruby location
which ruby # ~/.asdf/shims/ruby
# Check ruby version
ruby -v # ruby 3.4.6My dev environment setup involves tmux heavily and I use fish shell.
As soon as I opened a new session and started to work on my upgrade, it was weird.
# Launch a tmux session
tmux
# Check ruby version
ruby -v # 2.6.10Wait a minute! Why is it showing ruby version 2.6.10, not the newly installed 3.4.6?
And when I checked which ruby, as it turned out, it pointed to /usr/bin/ruby.
# Check ruby location
which ruby # /usr/bin/rubySo I did some digging and found out that the 2.6.10 version came with macOS at /usr/bin/ruby.
This issue only happened in tmux session because for some reason /usr/bin is loaded before ~/.asdf/shims in $PATH.
To fix this, I added the following snippet to my fish config ~/.config/fish/config.fish:
# Asdf
if test -z $ASDF_DATA_DIR
set _asdf_shims "$HOME/.asdf/shims"
else
set _asdf_shims "$ASDF_DATA_DIR/shims"
end
set -gx --prepend PATH $_asdf_shims
set --erase _asdf_shimsWhat this does is that ~/.asdf/shims is prepended to the $PATH which makes ruby load
from ~/.asdf/shims instead of /usr/bin/ruby.
Now when I open a new tmux session and run ruby -v, it shows the 3.4.6 consistently.
# Check ruby version
ruby -v # ruby 3.4.6So that's it, it works!