我正在使用mysql2
gem,由于某种原因,我无法运行rails server
命令。我已经尝试了stackoverflow中的所有解决方案,但似乎没有任何效果。这是输出。
$ rails s
/Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in `require': dlopen(/Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/mysql2-0.3.15/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/mysql2-0.3.15/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/mysql2-0.3.15/mysql2/mysql2.bundle
from /Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:76:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:72:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:72:in `block in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:61:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler/runtime.rb:61:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.0.pre.1/lib/bundler.rb:131:in `require'
from /Users/user/Desktop/simple_cms/basic_cms/config/application.rb:7:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.4/lib/rails/commands.rb:74:in `require'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.4/lib/rails/commands.rb:74:in `block in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.4/lib/rails/commands.rb:71:in `tap'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.4/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
答案 0 :(得分:2)
尝试将此添加到.bash_profile
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
答案 1 :(得分:2)
感谢大家的帮助。我找到了解决方案,虽然我不知道如何解释它。这就是我所做的。
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib