简体   繁体   English

WEBrick无法使用Rails Server命令

[英]WEBrick is not working with rails server command

I'm new to RoR and I can't seem to get WEBrick up and listening. 我是RoR的新手,我似乎无法起身并收听WEBrick。 Here is the console output. 这是控制台输出。 I use Mountain Lion, Rails 3.2.8 and Ruby 1.9.3. 我使用Mountain Lion,Rails 3.2.8和Ruby 1.9.3。 Help please 请帮助

/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>'

the answer is here: 答案在这里:

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

rails + MySQL on OSX: Library not loaded: libmysqlclient.18.dylib OSX上的rails + MySQL:未加载库:libmysqlclient.18.dylib

--- EDITED -编辑

Your $DYLD_LIBRARY_PATH does not contains /usr/local/mysql/lib directory, so there are 2 solution 您的$ DYLD_LIBRARY_PATH不包含/ usr / local / mysql / lib目录,因此有两种解决方案

  • symlink 符号链接
  • add /usr/local/mysql/lib to $DYLD_LIBRARY_PATH in .bashrc or somewhere 将/ usr / local / mysql / lib添加到.bashrc中的$ DYLD_LIBRARY_PATH或其他位置

Don't know if this answer is helpful or not ... but I ran into the same problem of sorts this week. 不知道这个答案是否有帮助...但是本周我遇到了同样的问题。

When I googled around for an answer, the one that I found helpful was just to put gem 'thin' in Gemfile. 当我在谷歌上寻找答案时,我发现很有帮助的只是将gem'thin'放入Gemfile中。

(of course, this is reliant on having installed the thin gem already) (当然,这取决于已经安装了薄的宝石)

Then run bundle install after that. 然后运行捆绑安装。 (this installs the thin gem). (这将安装薄宝石)。

When you run rails server, it'll work with thin automatically. 当您运行Rails Server时,它将自动与Thin一起使用。

Hope this helps! 希望这可以帮助!

edit: changed bundle to bundle install 编辑:将捆绑软件更改为捆绑软件安装

edit 2: added the sentence about thin gem 编辑2:增加了关于稀薄宝石的句子

It looks like your mysql2 gem is not properly installed. 看来您的mysql2 gem没有正确安装。 Take a look at the answer to this question. 看看这个问题的答案。 It should help you set it up. 它应该可以帮助您进行设置。 You need to first install mysql (I like using homebrew to do this). 您需要先安装mysql(我喜欢使用自制软件来执行此操作)。 Then gem install with the proper path. 然后使用正确的路径安装gem。

Ruby gem mysql2 install failing Ruby gem mysql2安装失败

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

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