3

我很长一段时间都遇到了rails问题,我尝试了很多我在这里发现的类似问题的答案,但是虽然其中一些对一些错误有效,但我一直卡住并且无法解决这个问题,我尝试了大多数解决方案对于我发现并最终决定问自己的类似问题,此错误仅在启动此特定项目的服务器时发生,而服务器为新的空 rails 项目正常启动:

$ rails server
/Users/celorisoli/.rvm/gems/ruby-1.9.2-p320/gems/mysql2-0.3.11/lib/mysql2.rb:9:in    `require': dlopen(/Users/celorisoli/.rvm/gems/ruby-1.9.2-p320/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/mysql/lib/libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: no suitable image found.  Did find:
/usr/local/mysql/lib/libmysqlclient.18.dylib: mach-o, but wrong architecture
/usr/local/mysql/lib/libmysqlclient.18.dylib: mach-o, but wrong architecture
/usr/lib/libmysqlclient.18.dylib: mach-o, but wrong architecture - /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `<top (required)>'
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `each'
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `block in require'
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each'
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require'
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.2.1/lib/bundler.rb:128:in `require'
from /Users/celorisoli/logbook/config/application.rb:7:in `<top (required)>'
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.6/lib/rails/commands.rb:53:in `require'
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.6/lib/rails/commands.rb:53:in `block in <top (required)>'
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.6/lib/rails/commands.rb:50:in `tap'
from /Users/celorisoli/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.6/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

大多数答案有助于解决“找不到图像”的问题,但是这里的错误如下:

Reason: no suitable image found.  Did find:
4

1 回答 1

3

您需要找到 libmysqlclient.18.dylib 实际在您的机器上的位置,并使用正确的路径更新捆绑包。

例如,我的错误信息是:

/Users/rbotzer/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': dlopen(/Users/rbotzer/.rvm /gems/ruby-1.9.3-p392/gems/mysql-2.9.1/lib/mysql/mysql_api.bundle, 9):库未加载:libmysqlclient.18.dylib (LoadError)

我将 libmysqlclient.18.dylib 定位在 /usr/local/mysql-5.6.16-osx10.7-x86_64/lib/libmysqlclient.18.dylib

现在更新捆绑包:

sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql-5.6.16-osx10.7-x86_64/lib/libmysqlclient.18.dylib ~/.rvm/gems/ruby-1.9.3-p392/gems/ mysql-2.9.1/lib/mysql/mysql_api.bundle

这解决了我的问题。

于 2014-03-15T21:29:26.663 回答