简体   繁体   English

Ruby On Rails 3和Webrick问题

[英]Ruby On Rails 3 and Webrick issue

Thanks for taking a look at this. 感谢您对此的关注。

I started a beginner's tutorial on RoR through lynda.com. 我通过lynda.com开始了有关RoR的初学者教程。 I followed the instructions to the letter. 我遵循了这封信的指示。 Everything was working so far until I got to accessing Webrick. 到目前为止,一切正常,直到我访问了Webrick。 When I typed in "rails server" to begin work, I got this error message below. 当我输入“ 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

I'm using a 我正在使用

  • iMac iMac电脑
  • Ruby 1.87 红宝石1.87
  • Gem 1.7.2 宝石1.7.2

Since I'm not experienced with anything Ruby, I'm lost on how to fix this. 由于我对Ruby没有任何经验,因此我不知道如何解决此问题。

Thanks in advance for your attention and help if possible. 在此先感谢您的关注和帮助。

Run these at the terminal: 在终端上运行这些:

gem install bundler
bundle

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. 编辑 :您应该真正考虑使用rvm管理您的红宝石安装和宝石集。 It'll save you a lot of time and effort in installing them too. 它也将节省您大量的时间和精力来安装它们。

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. 我遇到了与您相同的问题(也尝试过Lynda课程),而且还是一个新手,我很快就感到沮丧。

Buuuuut, after some searching, I found and answer here I got it to work. Buuuuut,经过一番搜索后,我发现并回答了这个问题我开始工作了。

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. 首先,我安装了32位版本的MySQL,而不是64位版本,但是我不确定这是否有所作为。

Then, uninstall the Mysql gem 然后,卸载Mysql gem

 gem uninstall mysql2

then reinstall it 然后重新安装

sudo gem install mysql2

and finally 最后

sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle

and you should be good to go! 而且您应该很好走! Worked for me anyways. 反正为我工作。 good luck! 祝好运!

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

这是对我有用的代码:D

I had the same problem. 我有同样的问题。 I simply ran the following code: 我只运行了以下代码:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib

Press enter, and then run 按Enter,然后运行

rails server

and it worked! 而且有效!

Correct way that worked for me was: 对我有用的正确方法是:

cd ~ [command] cd〜 [命令]

nano .bash_profile [command] nano .bash_profile [命令]

add this line of code: 添加以下代码行:

export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH" 出口DYLD_LIBRARY_PATH =“ / usr / local / mysql / lib:$ DYLD_LIBRARY_PATH”

ctrl+x [save] Ctrl + x [保存]

y [yes] y [是]

cd Sites/sitename/ [command] cd站点/站点名称/ [命令]

rails server [run WEBrick server] rails服务器 [运行WEBrick服务器]

and you should get this message: 并且您应该收到此消息:

=> Booting WEBrick =>正在启动WEBrick
=> Rails 3.2.11 application starting in development on localhost:3000 => Rails 3.2.11应用程序正在localhost:3000上开发
=> Call with -d to detach =>用-d调用以分离

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM