Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
481 views
in Technique[技术] by (71.8m points)

ruby - How to use "RVM --default" on MacOSX

After using Ruby and Rails for quite some time now, I wanted to try RVM. Everything works fine, except for one thing:

In a freshly opened Terminal ruby points to the system's ruby, despite the fact, that I used the rvm --default command.

user@terra ~ $ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10]
user@terra ~ $ which ruby
/opt/local/bin/ruby
user@terra ~ $ rvm list
   ruby-1.8.7-p334 [ ]
=> ruby-1.9.2-p180 [ ]

Everything is fine after I call rvm reload

user@terra ~ $ rvm reload
user@terra ~ $ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.1]
tmangner@terra ~ $ which ruby
/Users/user/.rvm/rubies/ruby-1.9.2-p180/bin/ruby

I set up my .bash_profile as described in the documentation:

[[ -s "/Users/user/.rvm/scripts/rvm" ]] && source "/Users/user/.rvm/scripts/rvm" 

That --default does not seem to work for me ...

user@terra ~ $ rvm use 1.9.2 --default
Using /Users/user/.rvm/gems/ruby-1.9.2-p180
user@terra ~ $ rvm default
user@terra ~ $

I'm using Mac OS X Snow Leopard (10.6.6)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had the same problem once. It turned out the rvm-script got loaded twice, which broke things a bit.

Check all the files that load when you open a shell:

/etc/profile
~/.bashrc
~/.bash_profile

and so on, and make sure they don't load RVM twice.

Maybe put

echo "Going to load RVM"

before

[[ -s "/Users/user/.rvm/scripts/rvm" ]] && source "/Users/user/.rvm/scripts/rvm"

in your ~/.bash_profile to see if it happens or not.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...