Installing ruby mysql gem in OSX 10.5 (Leopard)

November 9, 2007

It took awhile, but I've finally switched over to OSX - and from what I can tell by googling for "OSX Ruby mysql gem", have gone through what seems to be an initiation.

There are many, many, many posts on how to make it install - and most of them didn't work for me. I did get it to work though and actually quite easily once i figured out what to do, so I figured I'd post yet another blog on the subject detailing how it worked, for me.

sudo su 
ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/usr/local/mysql

This made it install, but requiring mysql caused it to explode.. to fix that:

install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle

The install_name_tool changes where the mysql.bundle looks for the dylib file - by default it was looking in mysql/lib/mysql instead of mysql/lib. The gem install command that worked I found on wishingline.com and some info on the install_name_tool fix was found in this thread.

Hopefully this will be helpful for somebody else trying to install the ruby mysql gem on leopoard!

Update: Rein has posted a cleaner solution.

1 Michael Whittaker: November 19, 2007

Thanks a lot, I also had trouble building the extension with the Archflag and MySQL-Dir it worked! :)

2 Brett A. Rogers: December 6, 2007

Worked Like a champ! Thanks!

3 Tobi: December 12, 2007

yeah worked for me as well! Great job - Thanks!

4 Ross: December 16, 2007

Thanks for people out there like you that take the time to post their solutions.

5 Nathan: December 18, 2007

Thanks for the tips, these worked like a charm and fixed a bug we were having using ActiveWarehouse.

6 mike: January 1, 2008

Thanks man, really cool post

7 diana: January 9, 2008

Thank you loads! Saved my hours of tracing the solution!

8 adam : January 20, 2008

u da man . thanks heaps!

9 Andy Callaghan: February 2, 2008

Thanks a lot! This finally worked for me!

10 Miro Holopainen: February 11, 2008

Thank You! Being an OSX/ruby newb, I spent a few days on this and would've spent more if it wasn't for your solution!

11 Justin: June 16, 2008

worked for me, on OSX 10.5.3. FINALLY! Thanks :D

Add comment

About

I'm a programmer and shutterbug living on the West Coast of Canada.

Blog Archive

Recently Heard

A Liberal Educationby New Model ArmyPlayed on 2008/07/16 at 02:35PM
The Two Sides of Monsieur Valentineby SpoonPlayed on 2008/07/16 at 02:32PM
You Weren't Thereby New Model ArmyPlayed on 2008/07/16 at 02:28PM
Powered by Viviti