0

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>'
Irfy
  • 2,469
  • 4
  • 25
  • 31

3 Answers3

3

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
Community
  • 1
  • 1
sumskyi
  • 1,827
  • 13
  • 13
  • Thank you very much, this solved my problem right away. Would you be so kind to explain what this did? I'm trying to learn and am a newbie to Ruby and to Rails – Adham Abdel Sep 14 '12 at 07:06
1

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

0

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

Community
  • 1
  • 1
George
  • 658
  • 5
  • 12