Article / November 5, 2009

[SOLVED] 64bit MySQL and 32bit Ruby: FAIL

By David Palm/679 Views/0 Comments

For the people out there using RVM to rock multiple Ruby versions, here's a gotcha with REE and Snow Leopard that took me hours to solve: if you happened to boot your mac in 32-bit mode when building ree with the oh so awesome:

rvm install ree

And then install MySQL 64bit and try to install the gem, ruby will positively hate you. It will also do it's best not to help you understand the issue whining about missing libraries and whatnot.

No, it's not a library issue. Your ruby is built for 32bit and the mysql libs are 64bit. I know for sure nokogiri has the same issue and I think many others as well.

What kernel version am I running?

~# uname -m
x86_64

~# uname -m
i386

To force 64bit mode, reboot holding down the "6" and "4" keys on the keyboard.

Recompiling your rubies is fun for sure, but if you get tired of it, here's how to make the 64bit switch permanent:

~# sudo vim /Library/Preferences/SystemConfiguration/com.apple.Boot.plist

Change the last key to arch=x86_64. You'll end up with:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Kernel</key>
        <string>mach_kernel</string>
        <key>Kernel Flags</key>
        <string>arch=x86_64</string>
</dict>
</plist>
To check if a lib is 64bit, run:

~# lipo -info /usr/local/mysql/lib/libmysqld.a 
input file /usr/local/mysql/lib/libmysqld.a is not a fat file
Non-fat file: /usr/local/mysql/lib/libmysqld.a is architecture: x86_64

What about my ruby version?

~# lipo -info ~/.rvm/ree-1.8.7-2009.10/lib/libruby-static.a 
input file /Users/david/.rvm/ree-1.8.7-2009.10/lib/libruby-static.a is not a fat file
Non-fat file: /Users/david/.rvm/ree-1.8.7-2009.10/lib/libruby-static.a is architecture: x86_64

~# lipo -info ~/.rvm/ruby-1.9.1-p243/lib/libruby-static.a 
input file /Users/david/.rvm/ruby-1.9.1-p243/lib/libruby-static.a is not a fat file
Non-fat file: /Users/david/.rvm/ruby-1.9.1-p243/lib/libruby-static.a is architecture: i386
</code

Looks like I'll have to nuke my Ruby 1.9 install too. Sigh.

Give us the fix already!

Ok ok. Here it goes:

# One
echo "rvm_archflags='-arch x86_64'" > ~/.rvmrc

Now rvm will now know what we want.

That's not enough though and we need to make sure REE doesn't build with tcmalloc (at least until the good people at Google solve the non-64bit-ness of it). Only thing is rvm as of v0.64 has a little bug stopping params to be passed along. The soon to be released v0.75 fixes this but for now you need head:

# Two
rvm rvm update --head

Now we're ready to reinstall REE:

# Three
rvm --force install ree --ree-options --no-tcmalloc

Many thanks to wayneeseguin for helping with this issue! Rvm is the best thing since sliced bread.

Comments

Interesting post?  Show some love and post a comment!
Using pieces of this code?  Post a link!

Add a Comment