Ruby On Rails 3 和 Webrick 问题
感谢您查看此内容。
我通过 lynda.com 开始了关于 RoR 的初学者教程。我严格按照指示进行操作。到目前为止一切正常,直到我开始访问 Webrick。当我输入“rails server”开始工作时,我收到下面的错误消息。
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
from /Users/macuser/Sites/simplecms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
我使用的是
- iMac
- Ruby 1.87
- Gem 1.7.2
由于我对 Ruby 没有任何经验,所以我不知道如何解决这个问题。
预先感谢您的关注和帮助(如果可能)。
Thanks for taking a look at this.
I started a beginner's tutorial on RoR through lynda.com. I followed the instructions to the letter. Everything was working so far until I got to accessing Webrick. When I typed in "rails server" to begin work, I got this error message below.
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
from /Users/macuser/Sites/simplecms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
I'm using a
- iMac
- Ruby 1.87
- Gem 1.7.2
Since I'm not experienced with anything Ruby, I'm lost on how to fix this.
Thanks in advance for your attention and help if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在终端运行这些:
然后您应该能够启动服务器。
编辑:您确实应该考虑使用 rvm 来管理您的 ruby 安装和 gemset。它也会为您节省大量的安装时间和精力。
Run these at the terminal:
And then you should be able to boot the server.
Edit: You should really look into using rvm to manage your ruby installs and gemsets. It'll save you a lot of time and effort in installing them too.
我遇到了和你一样的问题(也试图完成 Lynda 课程),而且作为一个新手,我很快就感到非常沮丧。
Buuuuut,经过一番搜索,我找到并回答了这里我让它工作了。
首先,我安装了 32 位版本的 MySQL,而不是 64 位版本,但我不确定这是否有区别。
然后,卸载 Mysql gem
,然后重新安装它
,最后
就可以开始了!无论如何为我工作。祝你好运!
I ran into the same problem as you (also attempting to go through the Lynda course), and also being a newbie I got pretty frustrated pretty quickly.
Buuuuut, after some searching, I found and answer here I got it to work.
First, I installed the 32-bit version of MySQL, as opposed to the 64-bit version, but I'm not sure if that made a difference.
Then, uninstall the Mysql gem
then reinstall it
and finally
and you should be good to go! Worked for me anyways. good luck!
这是对我有用的代码:D
This is the code that worked for me :D
我也有同样的问题。我只是运行了以下代码:
按 Enter 键,然后运行
,它就工作了!
I had the same problem. I simply ran the following code:
Press enter, and then run
and it worked!
对我有用的正确方法是:
cd ~ [command]
nano .bash_profile [command]
添加这行代码:< /em>
ctrl+x [保存]
y [是]
cd Sites/sitename/ [命令]
rails 服务器 [运行 WEBrick 服务器]
,您应该收到此消息:
Correct way that worked for me was:
cd ~ [command]
nano .bash_profile [command]
add this line of code:
ctrl+x [save]
y [yes]
cd Sites/sitename/ [command]
rails server [run WEBrick server]
and you should get this message: