Ruby On Rails 3 和 Webrick 问题

发布于 2024-11-02 00:02:02 字数 1769 浏览 0 评论 0原文

感谢您查看此内容。

我通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

落花浅忆 2024-11-09 00:02:02

在终端运行这些:

gem install bundler
bundle

然后您应该能够启动服务器。

编辑:您确实应该考虑使用 rvm 来管理您的 ruby​​ 安装和 gemset。它也会为您节省大量的安装时间和精力。

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. It'll save you a lot of time and effort in installing them too.

烟─花易冷 2024-11-09 00:02:02

我遇到了和你一样的问题(也试图完成 Lynda 课程),而且作为一个新手,我很快就感到非常沮丧。

Buuuuut,经过一番搜索,我找到并回答了这里我让它工作了。

首先,我安装了 32 位版本的 MySQL,而不是 64 位版本,但我不确定这是否有区别。

然后,卸载 Mysql gem

 gem uninstall mysql2

,然后重新安装它

sudo gem install mysql2

,最后

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

就可以开始了!无论如何为我工作。祝你好运!

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

 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!

温柔嚣张 2024-11-09 00:02:02
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

这是对我有用的代码:D

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

This is the code that worked for me :D

無心 2024-11-09 00:02:02

我也有同样的问题。我只是运行了以下代码:

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

按 Enter 键,然后运行

rails server

,它就工作了!

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

rails server

and it worked!

在你怀里撒娇 2024-11-09 00:02:02

对我有用的正确方法是:

cd ~ [command]

nano .bash_profile [command]

添加这行代码:< /em>

导出 DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"

ctrl+x [保存]

y [是]

cd Sites/sitename/ [命令]

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

,您应该收到此消息:

=>启动 WEBrick
=> Rails 3.2.11 应用程序开始在 localhost:3000
上开发
=>使用 -d 调用来分离

Correct way that worked for me was:

cd ~ [command]

nano .bash_profile [command]

add this line of code:

export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"

ctrl+x [save]

y [yes]

cd Sites/sitename/ [command]

rails server [run WEBrick server]

and you should get this message:

=> Booting WEBrick
=> Rails 3.2.11 application starting in development on localhost:3000
=> Call with -d to detach

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文