postmodern / chruby

Changes the current Ruby
MIT License
2.86k stars 190 forks source link

Creating a new tab in terminal doesn't keep the .ruby-version #321

Closed countingtoten closed 9 years ago

countingtoten commented 9 years ago

On Mac OS X 10.10.2 opening a new Terminal tab doesn't keep the .ruby-version even though we are in the same directory.

$ ruby -v ruby 2.1.5p273 ... $ cd ~/Code/project $ ruby -v jruby 1.7.9 (1.9.3p392) ... Cmd+T to create a new tab $ ruby -v ruby 2.1.5p273 ... $ cd ../ $ cd project $ ruby -v jruby 1.7.9 (1.9.3p392) ...

aprescott commented 9 years ago

I'm constantly bitten by this too.

countingtoten commented 9 years ago

I think it's because I declare a default ruby in my .bash_profile after I load the chruby and auto scripts, but I don't know how to fix it...

# ~/.bash_profile
if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then
  source /usr/local/share/chruby/chruby.sh
  source /usr/local/share/chruby/auto.sh
fi

chruby ruby-2.1.5
postmodern commented 9 years ago

Yep that will override the current ruby. Better to just upgrade system ruby to your desired version. Or create a ~/.ruby-version file.

aprescott commented 9 years ago

I suppose .bashrc/.zshrc could also check to see if pwd has a .ruby-version and then source that, to handle a new terminal tab starting out in a non-~ directory?