0

我是 RoR 的新手,我似乎无法启动 WEBrick 并倾听。这是控制台输出。我使用 Mountain Lion、Rails 3.2.8 和 Ruby 1.9.3。请帮忙

/Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require': dlopen(/Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `<top (required)>'
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `require'
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `each'
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `each'
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `require'
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.2.0/lib/bundler.rb:128:in `require'
    from /Users/Adham/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
    from /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
4

3 回答 3

3

答案在这里:

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

OSX上的rails + MySQL:未加载库:libmysqlclient.18.dylib

--- 已编辑

你的 $DYLD_LIBRARY_PATH 不包含 /usr/local/mysql/lib 目录,所以有2个解决方案

  • 符号链接
  • 将 /usr/local/mysql/lib 添加到 .bashrc 或某处的 $DYLD_LIBRARY_PATH
于 2012-09-14T07:02:18.120 回答
1

不知道这个答案是否有帮助......但我本周遇到了同样的问题。

当我在谷歌上搜索答案时,我发现有用的只是将 gem 'thin' 放入 Gemfile。

(当然,这取决于已经安装了薄宝石)

然后运行 ​​bundle install 之后。(这会安装薄宝石)。

当您运行 rails server 时,它会自动与 Thin 一起使用。

希望这可以帮助!

编辑:更改捆绑包安装

编辑2:添加了关于薄宝石的句子

于 2012-09-14T06:46:02.153 回答
0

看起来你的 mysql2 gem 没有正确安装。看看这个问题的答案。它应该可以帮助您进行设置。您需要先安装 mysql(我喜欢使用自制软件来执行此操作)。然后使用正确的路径安装 gem。

Ruby gem mysql2 安装失败

于 2012-09-14T07:03:01.737 回答