How To: Upgrade Ruby on OSX Leopard

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Monday, 26 January 2009

Just tested this and works ok. Leopard comes with 1.8.6, my box has 1.8.7 so best to keep them uniform for better code reliance.

What this'll do is replace your current version of Ruby without replacing the one supplied by Apple. Their's is stored in /usr/bin/ruby, your's will be stored in /usr/local/bin/ruby then hooked up with the PATH directive.

So in Terminal

sudo port install wget

wget ftp://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz
tar -xzvf stable*.tar.gz
cd ruby

Configure & Build Ruby for Leopard

./configure --prefix=/usr/local --enable-pthread
sudo make
sudo make install

Add the files to your Terminal's path

mate ~/.bash_profile

Add and Save this line

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

Refresh Terminal,

ruby -v
=> ruby 1.8.7 (2009-01-23 revision 0) [i386-darwin9.6.0]
Gems

Because this'll effectively give you another version of Ruby taking over from the supplied one, you'll have to re-install RubyGems, sorry....

wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar -xzvf rubygems*.tgz
cd rubygems*

sudo ruby setup.rb

Here's some install commands to get you started from my last setup

sudo gem install rails rake mysql mongrel mongrel_cluster thin capistrano termios sqlite3-ruby mini_magick ZenTest liquid rcov RubyInline image_science

MySQL is a pig on Leopard so this will get that gem working again

sudo env ARCHFLAGS="-arch i386" gem install mysql -- \  --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \  --with-mysql-include=/usr/local/mysql/include

Then some of my favourites...

gem sources -a http://gems.github.com
sudo gem install ultrasphinx rdiscount RedCloth twitter4r mislav-will_paginate fastercsv

...gotta dash, still on season 2 of 24, girlfriend won't let me watch day 7 until i've seen the rest ;-)

Comments
  1. JohnnyThursday, 29 January 2009
    Here's what's inside that stable...gz file:
    /ruby>dir
    total 8
    drwxr-xr-x 4 103 staff 136 Jan 28 12:10 ./
    drwxr-xr-x+ 41 jsainz staff 1394 Jan 29 10:00 ../
    -rw-r--r-- 1 103 staff 339 Jul 15 2008 KNOWNBUGS.rb
    -rw-r--r-- 1 103 staff 0 Jan 28 11:10 parse.y.tmp

  2. indieheadTuesday, 03 February 2009
    strange, worked great for me, did it on two servers.
  3. BundleThursday, 02 July 2009
    Everything worked fine up until I reached this part in the "Gems" section:
    sudo ruby setup.rb

    My result is:
    in `initialize': Malformed version number string 1.8.8.-1 (ArgumentError)
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:676:in `new'
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:676:in `ruby_version'
    from /usr/local/bin/gem:14

    I don't know how to fix this. Any chance you can help me? Thanks.
  4. peteMonday, 06 July 2009
    thanks for the quick no-fuss tip.
    I also love the fact that you don't have 100 clueless postings that begin with 'i did the 1st step and it worked great then....' from morons in midwestern states who shouldn't be using apple equipment.
  5. dtsFriday, 18 September 2009
    Very helpful.