我已经有很长一段时间使用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:
答案 0 :(得分: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 `需要“: 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 /宝石/红宝石1.9.3-P392 /宝石/ MySQL的-2.9.1 / lib中/ MySQL的/ mysql_api.bundle
这解决了我的问题。