I’ve been happily beavering away with the stock install of 1.8.6 on Mac OS X 10.5, but it seemed like everyone was moving on to Ruby 1.9 so I thought I’d make the leap. Was it a good idea? More on that later, but first here’s how I successfully installed it on my MacBook, based on instructions from http://hivelogic.com/articles/2007/02/ruby-rails-mongrel-mysql-osx. That page has a good detailed commentary of what’s going on, but didn’t actually work correctly for me, perhaps because of recent changes to the code in question. My version is short and sweet too, for those that either don’t care for the whys and wherefores, or find the command lines self-documenting enough.

Ruby 1.9 Install Instructions

Note: following these instructions will install new ruby and irb binaries in /usr/local/bin. The old system versions will still exist in /usr/bin/, but the new ones will take precedence by virtue of the PATH setup noted below.

  1. Ensure the following is at end of your ~/.bash_login:
    export PATH=”/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH”

  2. Reload that modified file so your environment picks it up (or just open a new terminal):
    > source ~/.bash_login

  3. Download and install libreadline.dylib as follows:
    > curl -O ftp://ftp.gnu.org/gnu/readline/readline-5.1.tar.gz
    > tar xzvf readline-5.1.tar.gz
    > cd readline-5.1
    > ./configure –prefix=/usr/local
    > make CPPFLAGS=-DNEED_EXTERN_PC SHOBJ_LDFLAGS=-dynamiclib
    > sudo make install

  4. Download and install latest Ruby 1.9 (or instead of living on the bleeding edge, download a tar of a stable source tree from http://www.ruby-lang.org/en/downloads/ in place of the first step below):
    > svn co http://svn.ruby-lang.org/repos/ruby/trunk ruby_trunk
    > cd ruby_trunk
    > autoconf
    > ./configure –prefix=/usr/local –enable-pthread –with-readline-dir=/usr/local –enable-shared
    > make
    > sudo make install

That’s it! Now assuming your PATH is setup as above, ruby –version should report 1.9. If not, check that ‘which ruby’ reports /usr/local/bin/ruby.

So What Next?

What next indeed! I thought I’d try and run a simple ruby app of mine to see if it worked. It didn’t, but that’s because the new ruby install keeps its gems in a different location and its cupboard was bare. I set out to reinstall the gems I needed, but I ran into some problems. Some gems just won’t install, because they have C extensions that are incompatible with Ruby 1.9 so they fail to compile during gem install. Others installed fine but then failed at runtime due to Ruby compatibility issues. There’s a great page with the major porting tips at http://boga.wordpress.com/2008/04/15/ruby-19-porting-notes/ which helped me fix most of the Ruby issues. Here’s a breakdown of my struggles:

  • Ramaze worked great as it’s been 1.9 compatible for ages.
  • The mysql gem only installed successfully by downloading the 2.8pre4 code from http://tmtm.org/downloads/mysql/ruby/ and following the install instructions.
  • The tens of gems that constitute DataMapper (my current ORM of choice) struggled. I was able to make simple Ruby changes to fix many bits, but I ran into real issues getting the database adapter gems do_mysql and do_sqlite3 to install as their C extensions are incompatible.
  • I don’t think my own code ever really got to run, so I have no idea if it’s good or not. I suspect it’s fine or requires minimal Ruby mods.

So I ran out of time and gave up as I’ve never gotten into the C extension side of things before and didn’t fancy starting. Perhaps I’d be able to sort it out if I put the time and effort in.

Overall it’s shown me that Ruby 1.9 is only worth the effort if all the gems you require are already compatible. I kind of already knew that before I embarked on this mission, but hoped that I’d be pleasantly surprised, or be able to do the porting myself with minimal effort. I was a bit disappointed to find things lagging behind as I assumed the Ruby community were eager technologists always at the forefront of each new thing! Maybe people are too busy coding solutions to their real world problems to bother with 1.9 until it’s declared official (late 2008 at last mention). I also get the impression they’ve become jaded with the extremely long gestation period for this release. Maybe I’ll try 1.8.7. One step at a time.

3 Comments

  1. Did you ever have any luck getting do_sqlite3 installed in Ruby 1.9?

  2. No, I haven’t tried since. I’ve been sticking with 1.8.6 or 1.8.7 (which is definitely worth the upgrade in general, for less bugs, a few 1.9 features and slightly better speed).

  3. we are currently preparing the ruby one-click installer for osx packages (leopard, tiger, panther) for ruby 1.9.1-p0 and 1.8.7-p72 — if you feel like helping out, you might want to take a look at the project page http://rubyosx.com or our mailing list. http://rubyforge.org/pipermail/rubyosx-list/

Leave a Reply

Your email address will not be published. Required fields are marked *