新手提醒...
试图解决我的 rails webrick 服务器的问题(即启动它),我使用了旧的 Stackoverflow 答案旧答案并执行了以下命令
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
但是,我忘记更改版本号。比如我的mysql是0.3.6(相对于命令中的0.2.6),也是libmysqlclient.18而不是.16。
现在,当我尝试启动 rails 服务器时,它说
Could not find gem 'mysql2 (~> 0.2.6)' in any of the gem sources listed in your Gemfile.
我试图用更新的版本重新运行这个命令,但它没有改变任何东西......事实上,它甚至没有询问我的 root 密码......有什么想法可以扭转这个问题吗?
更新 - 这是我这样做时产生的宝石列表gem list
。第一个回答这个问题的人建议(在他的评论中)我卸载了 mysql .0.2.6 但从未安装过那个 gem。当我执行上述name_tool 命令时,它告诉系统查找mysql 0.2.6,而我应该告诉它查找mysql2-0.3.6。
abstract (1.0.0)
actionmailer (3.0.9, 3.0.7)
actionpack (3.0.9, 3.0.7)
activemodel (3.0.9, 3.0.7)
activerecord (3.0.9, 3.0.7)
activeresource (3.0.9, 3.0.7)
activesupport (3.0.9, 3.0.7)
arel (2.0.10)
builder (2.1.2)
bundler (1.0.14)
erubis (2.6.6)
i18n (0.5.0)
mail (2.2.19)
mime-types (1.16)
mysql2 (0.3.6)
polyglot (0.3.1)
rack (1.2.3)
rack-mount (0.6.14)
rack-test (0.5.7)
rails (3.0.9, 3.0.7)
railties (3.0.9, 3.0.7)
rake (0.9.1)
rdoc (3.8)
rubygems-update (1.8.5)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.27)
更新——按照 Eric Hu 的回答中的说明进行操作后,我rails server
从项目文件夹中运行时得到了这个结果
2011-07-26 01:49:17 rails s
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2.rb:9
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:66:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:66:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:55:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler.rb:120:in `require'
from /Users/michaelmitchell/Sites/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
更新——我按照埃里克在他的评论中建议的那样做了捆绑清单
Gems included by the bundle:
* abstract (1.0.0)
* actionmailer (3.0.9)
* actionpack (3.0.9)
* activemodel (3.0.9)
* activerecord (3.0.9)
* activeresource (3.0.9)
* activesupport (3.0.9)
* arel (2.0.10)
* builder (2.1.2)
* bundler (1.0.14)
* erubis (2.6.6)
* i18n (0.5.0)
* mail (2.2.19)
* mime-types (1.16)
* mysql2 (0.2.11)
* polyglot (0.3.1)
* rack (1.2.3)
* rack-mount (0.6.14)
* rack-test (0.5.7)
* rails (3.0.9)
* railties (3.0.9)
* rake (0.9.2)
* rdoc (3.8)
* thor (0.14.6)
* treetop (1.4.9)
* tzinfo (0.3.29)