1. Ruby 1.8 and 1.9 living together on Mac OSX

    19 April 2009

    Lately I’ve been playing with Ruby 1.9.1 But for my professional life I still need 1.8.6 So here is how I have them setup to live happily together.

    What you first want to do is, of course, install Ruby 1.9.1 (your tarball name might differ)

    > wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz
    > tar xvf ruby-1.9.1-p0.tar.gz
    > cd ruby-1.9.1-p0
    > autoconf
    > ./configure —prefix=/usr —enable-pthread
    > make
    Now before you install you should backup your current Ruby’s bin files…
    > sudo cp /usr/bin/ruby /usr/bin/ruby-1.8
    > sudo cp /usr/bin/irb /usr/bin/irb-1.8
    > sudo cp /usr/bin/gem /usr/bin/gem-1.8

    Okay, let’s continue with the install
    > sudo make install

    After this is complete confirm that Ruby 1.9.1 is installed
    > ruby —version
    > irb
    > RUBY_VERSION
    > exit

    Now, because we’re assuming that you’ll most likely be usining 1.8.6 most of the time still let’s restore it and backup the bins for 1.9.1

    > sudo mv /usr/bin/ruby /usr/bin/ruby-1.9
    > sudo mv /usr/bin/ruby-1.8 /usr/bin/ruby
    > sudo mv /usr/bin/irb /usr/bin/irb-1.9
    > sudo mv /usr/bin/irb-1.8 /usr/bin/irb
    > sudo mv /usr/bin/gem /usr/bin/gem-1.9
    > sudo mv /usr/bin/gem-1.8 /usr/bin/gem

    Now if you want an app to run with Ruby 1.9.1 just replace the first line of the script:

    #!/usr/bin/ruby
    with
    #!/usr/bin/ruby-1.9

    Happy Hacking!


    > ./configure —program-suffix=19

    The End