Gotcha! (side-effects really pain a lot)

I just upgraded to Snow Leopard and installed buildr which failed miserably.

/Library/Ruby/Gems/1.8/gems/rjb-1.1.9/lib/rjbcore.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/rjb-1.1.9/lib/rjbcore.bundle, 9): no suitable image found. Did find: (LoadError)
/Library/Ruby/Gems/1.8/gems/rjb-1.1.9/lib/rjbcore.bundle: no matching architecture in universal wrapper - /Library/Ruby/Gems/1.8/gems/rjb-1.1.9/lib/rjbcore.bundle

It turns out that I needed to rebuild rjb, the ruby-java bridge, but that failed too.

extconf.rb:48: JAVA_HOME is not set. (RuntimeError)

I was certain that JAVA_HOME was definitely set and it was pointing to the 64-bit Apple 1.6 JDK.  Digging in extconf.rb, it finds JAVA_HOME from the ENV hash

javahome = ENV['JAVA_HOME']

So, nothing weird about that too!  What’s going on?  I was installing buildr like this

sudo gem install buildr

The problem is that once you sudo, you are running with another environment, one without the JAVA_HOME variable.  So, the quick fix is simply

sudo env JAVA_HOME=$JAVA_HOME gem install '1.1.9' rjb
sudo env JAVA_HOME=$JAVA_HOME gem install buildr

I completely forgot about this side-effect.  Like all side-effects, it was painful – it just cost me an hour of  digging around looking at all sorts of other things.  But, more importantly, breaking fundamental assumptions (e.g. my environment is the sudo‘s environment) and zoning in on the root cause of the problem resulted in a very simple solution.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s