Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use "RVM --default" on MacOSX

Tags:

macos

ruby

rvm

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)

like image 814
DiegoFrings Avatar asked Apr 09 '11 11:04

DiegoFrings


People also ask

How do I change the default version of rvm?

Try running rvm --default 1.9. 2 instead. That works for me. Did you accidentally put the line to load rvm in your bashrc instead of your bash_profile ?

How do I change the default ruby on Mac?

Set Ruby version with rvm on Mac To set a default Ruby version with rvm, enter rvm --default use 3.0. 0 on the command line. To switch to the system ruby, enter rvm use system . To switch back to the default, rvm default .

How do I use a specific version of ruby?

Selecting a version of Ruby You'll need to install bundler 1.2. x or above to use the ruby keyword and bundler 1.13. x or above to use a Ruby version specifier. You can use the ruby keyword in your app's Gemfile to specify a specific version of Ruby.


2 Answers

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.

like image 157
PerfectlyNormal Avatar answered Sep 19 '22 18:09

PerfectlyNormal


Moving the initialization

[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm" 

in the bottom of ~/.bash_profile solved the problem for me.

like image 30
kennyadsl Avatar answered Sep 23 '22 18:09

kennyadsl