Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
845 views
in Technique[技术] by (71.8m points)

mysql - Rails on OSX 10.11 El Capitan: Library not loaded: libmysqlclient.18.dylib

Since I upgraded OSX to 10.11, I can't use MySQL with my Rails app anymore:

$ rails s
/Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require': dlopen(/Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/mysql2-0.3.20/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/mysql2-0.3.20/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/mysql2-0.3.20/lib/mysql2/mysql2.bundle
    from /Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
    from /Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'

I found other posts about similar issues, but I'm too much of a beginner in this respect, and versions changed since solving, etc.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The previous answer (pre El Capitan), was to create a symbolic link from mysql's lib directory for the library file into /usr/lib, like this:

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

However this now produces 'operation not permitted' due to OS X's integrity controls. This can be worked around by disabling this. However a much easier solution (and one I can verify has worked) is to just symlink it into /usr/local/lib instead:

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

Good ol' Apple.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...