gs icon indicating copy to clipboard operation
gs copied to clipboard

gs is not working when installing ruby using chruby

Open xxuejie opened this issue 12 years ago • 6 comments

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!

xxuejie avatar Dec 19 '13 14:12 xxuejie

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?

soveran avatar Dec 19 '13 16:12 soveran

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?

xxuejie avatar Dec 20 '13 01:12 xxuejie

Yes, that looks problematic. Not sure if there's a way to use chruby without running that code, though.

soveran avatar Dec 20 '13 02:12 soveran

@soveran What do you use, then, for ruby version management?

mongrelion avatar Mar 20 '14 16:03 mongrelion

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.

soveran avatar Mar 20 '14 17:03 soveran

@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

bemurphy avatar Apr 17 '14 03:04 bemurphy