Part of what I’m doing is actually learning Rails more than I knew it before. I’ve been working on random test apps, but now I’m trying to build something for real and I decided to start from scratch. Blew everything away, happily compiling/installing on my Mac and then I run into issues.

Basically, I got this error (I was trying to run rake db:migrate) on OS X:

dyld: NSLinkModule() error
dyld: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
Referenced from: /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Reason: image not found
Trace/BPT trap

The issue is that in the most recent builds of MySQL from mysql.com (I was using 5.0.41), the libraries are no longer in lib/mysql/ but just in lib. I couldn’t remember how to modify linkage in a compiled bundle, but after a bit of googling, I found a post detailing the answer. Just run:

sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib

/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle

That will take care of the issue. You can use the same tool for any library that’s pointing to the wrong place for a link. Not sure why or how this happened, but at some point I’ll probably look into it and submit a patch.