views:

80

answers:

3

How do I make ruby 1.9 the default version to use instead of the 1.8.x that is by default installed on os x?

Thanks.

+4  A: 

Hi,

look at this answer about RVM http://stackoverflow.com/questions/3243088/installing-rvm-ruby-version-manager

Mike
+1  A: 

I recommend installing the RVM tool from http://rvm.beginrescueend.com/ (it has instructions on installing it

It allows you to have multiple versions of ruby and gems. After installing RVM, then install the Ruby 1.9 you want, using:

rvm install ruby-1.9.1

To make it the default one:

rvm --default ruby-1.9.1

After this, it will be the default ruby.

christophercotton
I would avoid being too specific by not including the patch levelie: rvm --default 1.9.1
Alkaline
Sure, that is a good point.
christophercotton
+1  A: 

RVM is great for setting up multiple environments with different versions of Ruby and gems.

If you however just want to have Ruby 1.9 you can simply install it using MacPort. It will take precedence over the one already installed by default on OS X.

  1. Download MacPort if you haven't already. It's the Mac package manager.
  2. On a Terminal, use MacPort to install Ruby 1.9 and RubyGems
    sudo port selfupdate
    sudo port install ruby19
    sudo port install rb-rubygems

You should then have Ruby 1.9 installed and ahead on the path. Do a ruby -v to check. Use Ruby gems to install any other Ruby components like Rails.

Ports are installed in the /opt/local/bin directory and MacPort updates the PATH environment variable so that these are picked up before the /usr/bin pre-installed packages.

Alkaline
Yes, that is a good answer too. The only comment I would make, is that with RVM you can get different gem sets. Different gemsets are required if you are trying to do both Rails 2.x and Rails 3.0 work. Plus, I've had problems where one version of Ruby would break certain apps (because of bugs in the ruby interpreter).
christophercotton