9

I've upgraded to Rails 2.2.2 and installed the MySQL 2.7 gem and am seeing this error when I try to run a migration or start the server:

dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle

What's the fix?

Nathan Smith
  • 683
  • 1
  • 10
  • 24
Gabe Hollombe
  • 7,847
  • 4
  • 39
  • 44

4 Answers4

4

Answering my own question for the benefit of others.

I found the fix here.

Run:

sudo 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
sudo 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/mysql.bundle

Worked for me.

Nathan Smith
  • 683
  • 1
  • 10
  • 24
Gabe Hollombe
  • 7,847
  • 4
  • 39
  • 44
  • I had to change the order here (install_name_tool -change [old] [new]), but it worked for me too. – freitass Nov 18 '10 at 02:35
  • Didn't work for me, even when I changed the 15 to 18. Sytse's solution did work, though I have no idea what the difference is. – mcv Jul 17 '12 at 10:11
4

I had to remove the directory from the old references:

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

sudo install_name_tool -change libmysqlclient.18.dylib 
    /usr/local/mysql/lib/libmysqlclient.18.dylib
    /Library/Ruby/Gems/1.8/gems/mysql-2.7/mysql.bundle
Christian Specht
  • 35,843
  • 15
  • 128
  • 182
Sytse
  • 41
  • 1
  • This one worked for me, unlike Gabe Hollombe's solution. No idea what the difference is. – mcv Jul 17 '12 at 10:11
2

Using sudo can often lead to unexpected issues. What worked for me was uninstalling the mysql2 gem and reinstalling it.

gem uninstall mysql2 bundle

mujtaba
  • 143
  • 2
  • 7
1

If Gabe Hollombe solution doesn't works then try this

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

sudo install_name_tool -change libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.7/mysql.bundle
Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367