Nullcreations.net | Ramblings & Photography of Jerrett Taylor

Installing ruby mysql gem in OSX 10.5 (Leopard)

November 9th, 2007 | 10 comments

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.

1
2
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 of railsforum.com

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

update Rein has posted a cleaner solution

10 Comments

Posted by Michael Whittaker 5 months ago.

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

Posted by Brett A. Rogers 5 months ago.

Worked Like a champ! Thanks!

Posted by Tobi 5 months ago.

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

Posted by Ross 5 months ago.

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

Posted by Nathan 5 months ago.

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

Posted by mike 4 months ago.

Thanks man, really cool post

Posted by diana 4 months ago.

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

Posted by adam 3 months ago.

u da man . thanks heaps!

Posted by Andy Callaghan 3 months ago.

Thanks a lot! This finally worked for me!

Posted by Miro Holopainen 3 months ago.

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!

Musings

04.14.08

Trying to decide where to travel to? Wikitravel.org Random Page has the answers!

02.23.08

sd's embedded_actions has a new home on github

02.18.08

Very cool.

02.17.08

Open Source Food? - looks like a nice recipe site!

02.15.08

For anyone using capistrano with more than one target for deployment (staging, production), check out cap multistage

02.15.08

Wow, I just realized how bad my code blocks break my blog in safari. I should fix that!

01.27.08

Mike has created another nice netbeans theme - go check it out, if you use netbeans!

01.21.08

A handy tool, Rubular is a web based regex editor

01.15.08

Dan put together a sweet code editor plugin for mce with syntax highlighting etc.

12.13.07

On OSX? Add RubyImporter to Spotlight and search your source!

12.04.07

sd has released a new version of embedded_actions

11.27.07

RejectConf videos are online thanks to confreaks!

11.19.07

Good news - we upgraded a project at work to rails 2.0 rc2 and the speed to run specs dropped from 30-35 seconds to 10-15 seconds!

11.08.07

Eigenclass.org has a great big list of Ruby 1.9 changes that is being kept up to date!

11.06.07

Rein is working on a trac replacement in ruby called eskort , and it looks cool. More info on his goals