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.

Comments

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

Worked Like a champ! Thanks!

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

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

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

Thanks man, really cool post

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

u da man . thanks heaps!

Thanks a lot! This finally worked for me!

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!

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

Hey, thanks for this! This somehow works than anything i've found out there!

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

also works :)

Hi, all

The only one thing, which actually works for me:

sudo gem install mysql -- --with-mysql-config=`which mysql_config5`

Thank you,
Sincerely,
Igor,
http://www.MyTaskHelper.com

This worked for me and seems like the easiest method:

sudo gem install mysql -- --with-mysql-config=`which mysql_config`

Thanks for the article :)

I tried about 20 different solutions and configurations before this one, and this one worked. Thanks!

Using Leopard and the 32 bit version of Mysql 5.0.67

Add comment