gs is not working when installing ruby using chruby
I'm installing ruby using chruby, and I'm getting the following result(suppose the current directory is foo):
$ echo $GS_NAME
$ gs
$ echo $GS_NAME
foo
$ env | grep GEM
GEM_PATH=/Users/rafael/.gem/ruby/2.0.0:/Users/rafael/.rubies/ruby-2.0.0-p353/lib/ruby/gems/2.0.0:/Users/rafael/.gem/ruby/2.0.0
GEM_ROOT=/Users/rafael/.rubies/ruby-2.0.0-p353/lib/ruby/gems/2.0.0
GEM_HOME=/Users/rafael/.gem/ruby/2.0.0
.gs directory in current path(which exists) is not counted in GEM_PATH. Is there anything I'm doing the wrong way? Thanks for the help!
Hey @xxuejie, I can't give you a straight solution because I don't use chruby, but my guess is that it has to do with some code that is executed automatically by chruby when you start a new shell. Can you tell me which code related to chruby is there in your .bashrc?
Hi @soveran, thanks for the reply!
I checked my .zshrc file(i'm using zsh, but I think bash works the same way), and here's the lines related to chruby:
source /usr/local/opt/chruby/share/chruby/chruby.sh
source /usr/local/opt/chruby/share/chruby/auto.sh
chruby ruby-2.0.0-p353
For the related chruby.sh and auto.sh files, you can find them at here: https://github.com/postmodern/chruby/tree/master/share/chruby
I think the problem is just at here?
Yes, that looks problematic. Not sure if there's a way to use chruby without running that code, though.
@soveran What do you use, then, for ruby version management?
I don't have different ruby versions installed, I just use one from homebrew. But I know people are using update-alternatives (linux) with gs/dep without issues, and I'm almost sure people use gs/dep with rbenv/rvm too.
@xxuejie @mongrelion btw this is a bit hacky, but I wrapped that check in chruby with:
if [ -z "$GS_NAME" ]; then
and it seems to be working so far. Kinda dirty but, eh. Also if you are invoking chruby to start a default, make sure it's in .bash_profile and not .bashrc