Ruby / MacBook / Snow Leopard Upgrade

After upgrading to Snow Leopard, I was greeted with the following upon trying to run my latest Ruby application:

/path/to/gems/ruby-debug-base-0.10.3/lib/ruby_debug.bundle: dlopen(/path/to/gems/ruby-debug-base-0.10.3/lib/ruby_debug.bundle, 9): no suitable image found.  Did find: (LoadError)
/path/to/gems/ruby-debug-base-0.10.3/lib/ruby_debug.bundle: no matching architecture in universal wrapper -/path/to/gems/ruby-debug-base-0.10.3/lib/ruby_debug.bundle

/path/to/gems/linecache-0.43/lib/../lib/trace_nums.bundle: dlopen(/path/to/gems/linecache-0.43/lib/../lib/trace_nums.bundle, 9): no suitable image found.  Did find: (LoadError)
/path/to/gems/linecache-0.43/lib/../lib/trace_nums.bundle: no matching architecture in universal wrapper - /path/to/gems/linecache-0.43/lib/../lib/trace_nums.bundle

/path/to/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in `establish_connection': Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (dlopen(/path/to/gems/pg-0.8.0/lib/pg.bundle, 9): no suitable image found.  Did find: (RuntimeError)
/path/to/gems/pg-0.8.0/lib/pg.bundle: no matching architecture in universal wrapper - /path/to/gems/pg-0.8.0/lib/pg.bundle)

I did find a quick fix: basically, the native system gems need to be reinstalled for 64-bit gems:

I found a good script for doing this at:

http://stackoverflow.com/questions/1367380/snow-leopard-64-bit-ruby-gem-problem

From the irb interface, try this:

$ irb
  irb> `gem list`.each_line {|line| `sudo env ARCHFLAGS="-arch x86_64" gem install #{line.split.first}`}

After about 20 minute of trashing, my system was up and functional again!

— UPDATE —
As pointed out by Jeffrey Lee, this could be a little more verbose with the following modifications:

`gem list`.each_line {|line| puts "Installing #{line.split.first}"; `sudo env ARCHFLAGS="-arch x86_64" gem install #{line.split.first}`}
Advertisements