Broken Rubygems Upgrades

2 04 2008

As mentioned in the last post, while I was on semi-vacation up north in Michigan, I didn’t really have any way to access the internet. Also, my family didn’t really seem to understand the concept of ‘the zone’, of which I was trying to enter to work on some code. Oh well.

When I finally did get a connection on my laptop and sat down to work on git-wiki, which I’ve been hacking on, I saw that a new version of Rubygems had been released (My laptop is frequently behind on software versions, as I only use it consistently while traveling.) I thought it’d be prudent to do a gem update --system while checking the changes other people have been making to git-wiki on GitHub. Unfortunately, gem has a major flaw right now, or rake’s creation of Makefiles does, or some combination of the above are responsible. I haven’t yet figured out the responsible party. As far as I can tell, both tools were never meant to care about code that is to be compiled, and therein lies a flaw.

It seems that whenever Ruby extensions written in C are compiled (in this case the http11.bundle compiled for Mongrel), the compiler is forced to assume the architecture is i386 (PC), despite the fact that it was building on my old PowerPC-based Powerbook. gcc tends to fail at this step, and even after the Makefile is corrected there are errors on the Mac with Ruby redefining GNU C library functions for itself (instead of coming up with new functions to call that are ruby-specific). Further, the error in compiling isn’t handled by either rake or gem and the installation continues. This means the user tends to get a confusing error message sent out by Mongrel or whatever framework they’re using that uses a Mongrel:

In retrospect, this failure to compile C extensions is also the reason I was unable compile Ruby on my Sun Cobalt Qube 3 (an x86 based microserver, but lacking a modern OS with a packaging system). The Ruby compile tended to die at the stage that it was creating the socket extension to Ruby.

Back home now, I’ve cloned my laptop’s git-wiki /wiki repo back onto my desktop and thought about how best to track down the source of the compile issues, or who even to take the errors up with. There are any number of mailing lists and places I could complain about this problem. I thought instead that a blog post, even on a lowly blog such as mine, is probably the best course of action. And viola! This post was formed. Now, does anyone know what’s going on, and more importantly, how to fix this?

Update: So, this issue seems to stem mostly from having XCode 2.4 or older. I upgrade to 2.5 and noticed that I no longer had issues in the linking stage (the tool is ld, and it has to do with processor architectures and finding libraries, both of which changed between XCode versions). So now it works, unless I want to build universal binaries. (when I build stuff for myself, that’s not really a priority)

So if you get this issue and want to fix it, either upgrade to XCode 2.5 or upgrade to Leopard, which comes with XCode 3.0. This also means that Leopard users probably never had this particular error.