1
rake aborted!
dlopen(/Users/ava/.rvm/gems/ruby-2.0.0-p247/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
  Referenced from: /Users/ava/.rvm/gems/ruby-2.0.0-p247/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/ava/.rvm/gems/ruby-2.0.0-p247/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle`

Ran the following to resolve:

$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib \
             /usr/lib/libmysqlclient.18.dylib
ln: /usr/lib/libmysqlclient.18.dylib: File exists

My setup:

  • OSX 10.8.4
  • MySQL 5.1.71
  • libmysqlclient.16.dylib

    $ locate libmysqlclient.16.dylib
    /usr/lib/libmysqlclient.16.dylib
    /usr/local/Cellar/mysql51/5.1.71/lib/mysql/libmysqlclient.16.dylib
    
  • libmysqlclient.18.dylib

    $ locate libmysqlclient.18.dylib
    /usr/lib/libmysqlclient.18.dylib
    

In .bash_profile, I have

export PATH="/usr/local/bin:$HOME/.rvm/bin:$HOME/bin:$PATH"
export DYLD_LIBRARY_PATH=/usr/local/bin/mysql

How to get this rake running? Am I supposed to have libmysqlclient.18.dylib under /usr/local/Cellar/mysql51/5.1.71/lib/mysql too? If yes, how do I create it?

Community
  • 1
  • 1
Ava
  • 5,783
  • 27
  • 58
  • 86
  • Maybe describe how you got here? Everything about what you're doing screams "NO!" so it's hard to help you. – Nick Veys Aug 22 '13 at 19:16
  • `brew install --use-llvm mysql51` and then `mysql.server start` – Ava Aug 22 '13 at 19:58
  • After the above two commands, ran rake and got this error. Somewhere I have messed up the mysql installation but not able to figure out. – Ava Aug 26 '13 at 20:15

2 Answers2

2

Sorry, if I am mistaken; there is no Mac to check in details.

The error message clearly states, that the library mysql wants is:

/usr/local/lib/libmysqlclient.18.dylib

while the library you have is:

/usr/lib/libmysqlclient.18.dylib

That definitely means, that your mysql installation is somehow broken, but for the quick patch I would recommend soft linking:

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

You have likely misplaced arguments within your first solution try.

Aleksei Matiushkin
  • 119,336
  • 10
  • 100
  • 160
  • Can you please explain what it is doing? Why doesnt `locate libmysqlclient.18.dylib` show it under `/usr/local/lib/`? – Ava Aug 28 '13 at 18:22
  • 1
    It’s doing exactly what you’ve tried according to the solution, except of one humdrum thing: it states args in the _right_ order. `locate libmysqlclient.18.dylib` shows it where it is. And in your case it is in `/usr/lib` rathen than the expected `/usr/local/lib`. Sorry for libmysqlclient, sorry for Apple. – Aleksei Matiushkin Aug 29 '13 at 06:26
0

Instruct Mac OS X to find it as follows, if you are using Bash:

In your ~/.bash_profile:

export DYLD_LIBRARY_PATH=<location of mysqlclient.18.dylib>:$DYLD_LIBRARY_PATH

Restart terminal.

For example, I have the following:

$ ls -ld /usr/local/m*
lrwxr-xr-x   1 root  admin   27 May  5 14:28 /usr/local/mysql -> mysql-5.6.13-osx10.7-x86_64
drwxr-xr-x   3 root  wheel  102 May  5 13:13 /usr/local/mysql-5.5.29-osx10.6-x86
drwxr-xr-x  17 root  wheel  578 May  5 13:13 /usr/local/mysql-5.6.13-osx10.7-x86_64

$ head ~/.bash_profile
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
Sujoy Gupta
  • 1,424
  • 1
  • 10
  • 12