Andrew
Andrew

Reputation: 668

Upgrading Mac Ruby through Homebrew (Mac OS 10.7)

I'm having trouble setting up the compy 486 to use Ruby 1.9.3. I installed homebrew using _why's instructions (http://poignant.guide/book/expansion-pak-1.html) but when I check which version is installed it's still 1.8.7.

From what I understand this is because now there are two version of ruby installed. (See: How can I switch to ruby 1.9.3 installed using Homebrew?)

See:

Last login: Fri Feb 22 17:20:40 on ttys000
MacBook-Air:~ andrew$ brew install ruby
Error: ruby-1.9.3-p385 already installed
To install this version, first `brew unlink ruby'
MacBook-Air:~ andrew$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]
MacBook-Air:~ andrew$ 

I read I should install Ruby Version Manger, but when I try that I get problems.

MacBook-Air:~ andrew$ $ \curl -L https://get.rvm.io | bash -s stable --ruby
-bash: $: command not found

So is there an easy way I can access my newer version of ruby 1.9.3 even if it's not used by default?

Upvotes: 1

Views: 4795

Answers (2)

Austin Lin
Austin Lin

Reputation: 2564

I would suggest you use rbenv (https://github.com/rbenv/rbenv).

rbenv is simpler and lighter than RVM, plus it is friendly to your system (RVM overrides the CD and GEM commands which is somewhat worrisome).

Once you install rbenv (I would use homebrew, directions on the rbenv github page linked above) you can do this magic:

rbenv install 1.9.3-p392

Note that because RVM overrides basic system commands you cannot have RVM and rbenv installed together.

Upvotes: 4

kopischke
kopischke

Reputation: 3413

The fact you still get the system default Ruby even after installing a current version through Homebrew is a simple issue of $PATH definitions: OS X’ system Ruby is installed in /usr/bin, while Homebrew installs its version in /usr/local/bin, which, by default comes after /usr/bin in your $PATH.

To get the newly installed Ruby, specify the full binary path, i.e. /usr/local/bin/ruby. If you want to make that the default, you could, of course, use a Ruby version manager (RVM and rbenv being the best known ones), but simply altering your $PATH to put /usr/local/bin before /usr/bin will do the trick too.

Upvotes: 3

Related Questions