Snow Leopard with legacy macports and rubygems
We assume you had Leopard with standard Ruby shipped with OS, tons of macports and rubygems already installed. Then you install Snow Leopard on top of it (not clean install).
The problem is that standard 10.6 dynamic libraries all went 64 bit and could not be linked with 32 bit code. This could be fixed by rebuilding/reinstalling all the macports and rubygems.
1. Install the latest Xcode shipped with Snow Leopard.
2. “port” command will fail with a message about incompatible Tcl architecture. The proper version of macport is 1.8 which is not released yet. You can obtain it from SVN trunk and built it by hand (./configure && make && sudo make install). I have also added trunk version of ports to sources.conf (see the link above for instructions) to be sure that I have the latest SL-compatible ports in the list. Maybe this is was wrong assumption, but it worked for me just fine.
3. Remove all ports:$ sudo port -f uninstall installed
4. Update rubygems to 1.3.1 at least (please google for instructions).
5. Remove vendor gems (gem uninstall refuses to remove them and fails to do batch remove):
$ gem list | cut -d" " -f1 > installed_gems
$ sudo mv /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8.bak
$ sudo mkdir /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
Note: installed_gems file contains a list of all installed gems so that you can cat and xarg it for installing all gems back.
6. Uninstall all gems
$ sudo gem list | cut -d" " -f1 | xargs sudo gem uninstall -aIx
7. Make the rubygems use 64 bit architecture.
$ cat installed_gems | xargs sudo env ARCHFLAGS="-Os -arch x86_64 -fno-common" gem install --no-ri --no-rdoc
Note: it is NOT i686 (as I thought it should be), it is x86_64 instead.
Here are convenient aliases for “sudo gem install” for both architectures:
alias sgi32="sudo env ARCHFLAGS=\"-Os -arch i386 -fno-common\" gem install --no-ri --no-rdoc"alias sgi64="sudo env ARCHFLAGS=\"-Os -arch x86_64 -fno-common\" gem install --no-ri --no-rdoc"
You may also put alias sgi="sgi64" in your .bash_login on snow leopard.
Now we all can proceed doing productive work. \o/
References:
1. http://www.nabble.com/-MacPorts—19446:-openssl-fails-to-compile-on-x86_64-td23247203.html
2. http://jaredonline.posterous.com/got-mysql-to-work-with-rails-in-mac-os-106-sn
3. http://cho.hapgoods.com/wordpress/?p=158
