When tmuxinator is run via asdf, asdf does not switch Ruby version
Describe the bug
If tmuxinator is run with Ruby managed by the asdf version manager, asdf will not automatically select the correct version of Ruby in shells within the tmuxinator session, but always uses the version of Ruby used to execute tmuxinator.
To Reproduce
- Install asdf and the Ruby plugin.
- Install two different versions of Ruby, A and B
- Set the global Ruby version to A via
~/.tool-versions - Install tmuxinator in Ruby version A:
gem install tmuxinator - Create a directory D containing a
.tool-versionfile specifying Ruby version B. - Start a fresh tmuxinator environment and navigate to D.
- run
ruby -vand see that version A is reported.
Expected behavior
Ruby version B is reported.
Environment
- tmuxinator Version:
tmuxinator 3.3.1 - tmux Version:
tmux 3.4 - Ruby Version:
ruby 3.2.4 (2024-04-23 revision af471c0e01) [x86_64-linux] - OS: Debian Linux Trixie
Additional information
The problem is that when running Ruby via asdf, asdf prepends the explicit path to the Ruby version to PATH (this is running outside tmux):
$ which ruby
/home/paul/.asdf/shims/ruby
$ ruby -e 'puts *ENV["PATH"].split(":")'
/home/paul/.asdf/installs/ruby/3.2.4/bin
/home/paul/bin
/home/paul/.asdf/shims
/home/paul/.asdf/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
$ ruby -e 'system "which ruby"'
/home/paul/.asdf/installs/ruby/3.2.4/bin/ruby This path will always supersede the shims directory containing the shim that executes the intended Ruby version.
A workaround is possible:
gem uninstall tmuxinatorfor all asdf-managed ruby versions- install tmuxinator to use the system Ruby interpreter (via
gemor a package manager)
This is not a bug in tmuxinator per se, but tmuxinator contains some explicit code to solve a similar situation with rbenv:
tmuxinator debug blah
#!/bin/zsh
# Clear rbenv variables before starting tmux
unset RBENV_VERSION
unset RBENV_DIR
tmux start-server;
...I think this might be a difficult problem to solve: the only solution that springs to mind is to filter out the explicit path from PATH, but that feels fragile. tmuxinator is not at fault, but it would at least be helpful to document this problem so that others don't waste as much time as I did!
Source: tmuxinator/tmuxinator