Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to install Ruby 1.9 using Homebrew. I'm using Mac OS X Lion, so Ruby 1.8.7 is installed by default.

I've got Homebrew installed at /usr/local/bin/brew (well that's what it says if I run 'which brew')

It seems to be using the Ruby located in /usr/bin/ruby (again, from 'which ruby')

I've read tons of suggestions saying I should do something to the path variable; mine looks like this:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/bin/brew

Where am I going wrong? Why is the Homebrew version of Ruby not being used?

share|improve this question
up vote 1 down vote accepted

Bash checks all folders in $PATH for the first one containing the application you're looking for.

In some file (~/.profile, ~/.bashrc, ~/.bash_profilewill be a line adding/usr/local/bin` to your $PATH. It will look like this:

export PATH=$PATH:/usr/local/bin

Change the order to

export PATH=/usr/local/bin:$PATH

Now, the operating system will look into /usr/local/bin/ and use ruby from homebrew instead the system's native one.

share|improve this answer
    
I didn't actually have a line like you specified, but I added PATH=/usr/local/bin:$PATH as the first line in ~/.profile and that fixed it! Thanks – Jaco Pretorius Nov 4 '11 at 0:19

If you plan to use ruby , consider the use of Rvm (or rbenv) Rvm home page

Then:

brew update 
\curl -sSL https://get.rvm.io | bash -s stable

Follow instructions in prompts (you'll need to source some scripts ) something like "source ~/.rvm/scripts/..."

rvm list  # this list all rubies instaled 
rvm use 2.3.1  # this set env on ruby version you want to use 

This way you'll have an entire ecosytem with ruby gems by version according to ruby's version . Like :

 ~/.rvm/rubies/2.1.0/gem/toto.rb
 ~/.rvm/rubies/2.1.0/gem/tata.rb       
 ~/.rvm/rubies/2.3.0/gem/toto.rb
 ~/.rvm/rubies/2.3.0/gem/tata.rb

Then all dependencies are met and everything goes smoothly you can switch ruby version at any time with rvm use 2.x All version of rubies will be home based and installable with rvm withch is a great tool if you want use ruby regulary. If you want use the framework (Rails) it's installable by appending --rails to the prvious curl command like so :

\curl -sSL https://get.rvm.io | bash -s stable --rails

Default's sytem version on mac is a weird(and very old) one , consider also use 2.x version ;)

share|improve this answer
    
Ok i've edited the thing ;) – plombix Jun 3 at 11:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .