简体   繁体   中英

WEBrick is not working with rails server command

I'm new to RoR and I can't seem to get WEBrick up and listening. Here is the console output. I use Mountain Lion, Rails 3.2.8 and 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

--- EDITED

Your $DYLD_LIBRARY_PATH does not contains /usr/local/mysql/lib directory, so there are 2 solution

  • symlink
  • add /usr/local/mysql/lib to $DYLD_LIBRARY_PATH in .bashrc or somewhere

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.

(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.

Hope this helps!

edit: changed bundle to bundle install

edit 2: added the sentence about thin gem

It looks like your mysql2 gem is not properly installed. 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). Then gem install with the proper path.

Ruby gem mysql2 install failing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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