OSX 10.11 El Capitan上的Rails:未加载库:libmysqlclient.18.dylib [英] Rails on OSX 10.11 El Capitan: Library not loaded: libmysqlclient.18.dylib
问题描述
自从我将OSX升级到10.11之后,我就不能再在Rails应用中使用MySQL:
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.
推荐答案
上一个答案(在El Capitan之前)是创建从mysql的lib目录到库文件的符号链接到/usr/lib,如下所示:
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
但是由于OS X的完整性控制,这现在会产生不允许的操作".可以通过禁用此方法来解决此问题.但是,一种更简单的解决方案(我可以验证有效)是将其符号链接到/usr/local/lib中:
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
好的苹果.
这篇关于OSX 10.11 El Capitan上的Rails:未加载库:libmysqlclient.18.dylib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!