Sunday, December 11, 2011

installing rails on OSX with mysql

trying to install and use ruby on rails on OSX with a mysql installation made by hand in /usr/local/mysql


$ rails server/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/mysql-5.5.17-osx10.6-x86/lib/libmysqlclient.18.dylib (LoadError)  
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle  
Reason: no suitable image found.

I'm probably missing something about a correct installation on osx and with a correct distribution of mysql libraries but I've seen that the fastest way of getting rid of this problem was a:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

use the

sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql-5.5.15-osx10.6-x86_64/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle

should be the proper solution

2 comments:

Mark said...

This worked for me. Thank you!

Unknown said...

OMG thank you! This totally worked!