I am using source /usr/local/opt/chruby/share/chruby/auto.sh to auto change ruby to the version in .ruby-version, but unfortunately this only works on cd.
When I open an new tab in my mac terminal, it opens to the same directory I was in in the previous tab, but auto change does not work. My solution to this is to cd ..
and the cd
back in, which triggers the change. This is tiresome, obviously.
I tried to manually call the function chruby_auto
in the new tab, but this has no effect.
Can someone offer a solution of how to get my ruby version updated in this case? I would prefer an automatic solution, but will settle for a command to call.
Actually nevermind, I traced this back to an issue in the order of these calls in my .bashrc
Incorrect:
source /usr/local/opt/chruby/share/chruby/chruby.sh
source /usr/local/opt/chruby/share/chruby/auto.sh
chruby ruby-2.3.0
I turns out you must call the auto line AFTER the default line. Note that the default line must be after the chruby.sh line, as well.
Correct:
source /usr/local/opt/chruby/share/chruby/chruby.sh
chruby ruby-2.3.0 # default order important, if comes after auto.sh, will undo the auto change
source /usr/local/opt/chruby/share/chruby/auto.sh
So just leaving this answer here for posterity I guess