RedFurSnake

Saturday, June 21, 2008

Upgrading to Ruby 1.8.7 using MacPorts

I thought it would have been simple to upgrade to the latest version of Ruby (1.8.7) since I had previously used MacPorts to install 1.8.6. However, my first attempt went like this...
bash$ sudo port install ruby
---> Building ruby with target all
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_
lang_ruby/work/ruby-1.8.6" && make all " returned error 2
Command output: ruby: [BUG] Segmentation fault
ruby 1.8.6 (2007-03-13) [i686-darwin9.3.0]

make: *** [.rbconfig.time] Abort trap

Error: Status 1 encountered during processing.
First, I thought maybe macports itself was out of date (I hadn't used it for months)...
bash$ sudo port selfupdate
MacPorts base version 1.520 installed
Downloaded MacPorts base version 1.600
Configuring, Building and Installing new MacPorts base
selfupdate done!
Try to get Ruby again...
bash$ sudo port install ruby
---> Building ruby with target all
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_
lang_ruby/work/ruby-1.8.7-p22" && make all " returned error 1
Command output: sh: line 0: cd: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_
lang_ruby/work/ruby-1.8.7-p22: No such file or directory

Error: Status 1 encountered during processing.
A slightly different error, but still not working. A little reading on the macports page suggested that a clean might help, to remove any leftover build files...
bash$ sudo port clean --all ruby
---> Cleaning ruby
Third time lucky...
bash$ sudo port install ruby
...lots of output...
bash$ sudo port deactivate ruby
bash$ sudo port activate ruby
---> Activating ruby
---> The following versions of ruby are currently installed:
---> ruby @1.8.6_0
---> ruby @1.8.7-p22_1+thread_hooks
Error: port activate failed: Registry error: Please specify the full version as recorded in the port registry.
Just need to explicity activate the new version...
bash$ sudo port activate ruby @1.8.7-p22_1+thread_hooks
---> Activating ruby 1.8.7-p22_1+thread_hooks
And sure enough...
bash$ ruby -v
ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-darwin9.3.0]
Mission accomplished. Now just need to check that my app still works...

UPDATE 26 June: Looks like there are good reasons for updating to Ruby 1.8.7, since security vulnerabilities have been found in 1.8.5/6. Patches to the older versions seem to be causing some segmentation faults. Ruby 1.8.7 is the way to go, provided you are prepared to upgrade Rails to 2.1 (earlier versions are not compatible, hence the 1.8.6 patches).

5 comments:

JoJo said...

Erm, I could be missing something, but "gem update rails" did the trick for me.

Chris said...

You updated to Rails 2.1, but I'm talking about Ruby. Type ruby -v to find out which version you are using. Version 1.8.7 fixes some security issues and includes some performance improvements back-ported from the forthcoming 1.9 release.

Hopefully, you won't encounter the problems I had, but there are bound to be others that do, hence the post.

brooke r said...

Thanks for the post. The port clean command helped me get upgraded to ruby 1.9.1.

Rob said...

Thanks for the reminder. I'd forgotten that I'd used macports.

Chris said...

@Rob: It's funny you say that, I forgot I'd used it too for various things! Have a look at Porticus for a more Mac-like interface to MacPorts... Seems to help me remember...