Todd Pinkerton

ruby, gcc, and powerPC macs

Categories: Uncategorized, mac, rails, tech
Written By: todd

I’ve been having trouble with my rails installation for a while. Tests would fail but only every so often, and occasionally a Fixnum object would show up when something else was expected, crashing my app.

It turns out, ruby compiled wth gcc 4.0 on powerPC macs — which my laptop is one — is known to exhibit these strange behaviors. David Heinemeier Hansson himself mentioned this in this blog post.

Turns out, the solution is to set gcc to 3.3 mode, rebuild ruby and any dependent libraries. You can do this with ‘gcc_select 3.3′, then running configure, make, make install as usual.

On the way to finding this fix, I tried updating to Ruby 1.8.5 patchlevel 2. To get this to work, I had to configure, make, and install, then go into the source tarball in ext/readline and run :

cd ext/readline
> ruby extconf.rb
> make 
> sudo cp readline.bundle /usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.9.0
Those instructions came from this mailing list archive.

So if you’re running ruby patchlevel 2 — which is the latest ruby that works with rails 1.2.2 — make sure you compile with gcc 3.3, and copy over the readline bundle as described above.

I’m pretty disappointed this much hackery is required to get ruby working on my machine, which is a fairly standard platform. Ruby should “just work” with gcc 4.0, and the Makefile should do the right thing with the readline module as well. Grrr.
In the near future I hope to get an Intel mac to develop on, and have access to all the latest ruby/rails goodies on that. But at least now all my tests are passing, and I’m not getting any more strange Fixnum errors.

Leave a Reply

Featured & Popular Articles