Mavericks上的Rails + MySQL-未加载库:libmysqlclient.18.dylib [英] Rails + MySQL on Mavericks - Library not loaded: libmysqlclient.18.dylib

查看:66
本文介绍了Mavericks上的Rails + MySQL-未加载库:libmysqlclient.18.dylib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在本地主机(OSX Mavericks)上运行Rails(rails s)应用程序时,出现此错误

When I run a Rails (rails s) app on my localhost (OSX Mavericks), I get this error

message:/Users/adam/.rvm/gems/ruby-2.0.0-p481/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `require': dlopen(/Users/adam/.rvm/gems/ruby-2.0.0-p481/extensions/x86_64-darwin-13/2.0.0-static/mysql2-0.3.16/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /Users/adam/.rvm/gems/ruby-2.0.0-p481/extensions/x86_64-darwin-13/2.0.0-static/mysql2-0.3.16/mysql2/mysql2.bundle
  Reason: image not found - /Users/adam/.rvm/gems/ruby-2.0.0-p481/extensions/x86_64-darwin-13/2.0.0-static/mysql2-0.3.16/mysql2/mysql2.bundle
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `<top (required)>'
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `require'
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `each'
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `block in require'
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `each'
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `require'
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler.rb:132:in `require'
    from /Users/adam/rubydev/logistadvise/config/application.rb:7:in `<top (required)>'
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
    from /Users/adam/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

我不确定如何安装MySQL,但我猜它在名为Cellar的子文件夹中.

I am not sure how I already installed MySQL, but I guess it's in the subfolder called Cellar.

这是我的bash_profile的样子:

MYSQL=/usr/local/mysql/bin
export PATH=$PATH:$MYSQL
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
export PG_DUMP="/Applications/Postgres.app/Contents/MacOS/bin/"
#PATH=$PG_DUMP:$PATH
...

如何解决此问题?

推荐答案

我遇到了同样的问题.因为我将其与brew安装在一起,所以DYLD的位置已更改.试试这个:

I had the same problem. Because I installed it with brew, the location of the DYLD changed. Try this:

export DYLD_LIBRARY_PATH=/usr/local/mysql-5.1.67-osx10.6-x86_64/lib:$DYLD_LIBRARY_PATH

首先检查上面的路径是否存在,如下所示,并明显地相应地调整导出路径:

Check if the path above exists first with something like the following and obviously adjust the export path accordingly:

ls -1 /usr/local/mysql-5.1.67-osx10.6-x86_64

您可能可以建立符号链接或其他内容.这对我来说很烦人,但是使用正确的路径对我来说是固定的.

You could probably make a symbolic link or something. It was kind of annoying for me, but using the correct path fixed it for me.

并尝试which mysql检查您的路径中是否有mysql.如果您没有得到任何输出,则显然路径被弄乱了.

And also try which mysql to check if you have mysql in your path. If you don't get any output obviously the paths are messed up.

这篇关于Mavericks上的Rails + MySQL-未加载库:libmysqlclient.18.dylib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆