OpenSSL

Ruby 1.8.7 openssl Bus Error

by Irish on June 21, 2010

Recently I switched from using my local ruby install to using RVM for managing all my ruby installations. RVM is pretty awesome and I highly recommend it. I went ahead and installed a few versions of ruby that I’d like to use including, ruby 1.8.7 (for work projects) and 1.9.2 (for playing with rails 3).

I came across an issue though with my 1.8.7 install when trying to run a rake db:migrate:reset command with my current work project. It was along the lines of this:

$ rake db:migrate:reset
(in /Users/cirish/Projects/so-ch)
/Users/cirish/.rvm/rubies/ruby-1.8.7-tv1_8_7_173/lib/ruby/1.8/openssl/ssl.rb:31: [BUG] Bus Error
ruby 1.8.7 (2009-06-08 patchlevel 173) [i686-darwin9.8.0]

Abort trap
$

Well that’s no bueno. It turns out that this is happening because, I have two openssl installations. A system one and other that I installed through macports. The reason the bus error is being thrown is that my eventmachine gem wasn’t compiled with the same openssl lib as my ruby 1.8.7 install. We can confirm this by running the following:

$ ruby -rubygems -e" require 'openssl' "; echo $? 0
0 0

$ ruby -rubygems -e" require 'eventmachine'; require 'openssl' "; echo $?
/Users/cirish/.rvm/rubies/ruby-1.8.7-tv1_8_7_173/lib/ruby/1.8/openssl/ssl.rb:31: [BUG] Bus Error
ruby 1.8.7 (2009-06-08 patchlevel 173) [i686-darwin9.8.0]

Abort trap
134

At this point you could either recompile ruby and point it to the correct openssl lib or recompile eventmachine to use the system’s openssl. Since this was a new ruby install anyways, I chose to just recompile ruby.

$ rvm install ruby-1.8.7-tv1_8_7_174 --configure --enable-shared=true,--with-openssl-dir=/opt/local --debug

Now let’s check the install again

$ ruby -rubygems -e" require 'eventmachine'; require 'openssl' "; echo $?
0

Fixed :-)

{ 1 comment }