Search code examples
ruby-on-railsruby-on-rails-4rbenvrbenv-gemset

Rails Server Error - Rails 4


I am trying to come back to create another application on Rail4 and When I try to start the application this is what happened:

    prompt$ rails server
    /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/mysql2-0.4.5/lib/mysql2.rb:31:in `require': dlopen(/Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/mysql2-0.4.5/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
    Referenced from: /Users/edwincaro/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/mysql2-0.4.5/lib/mysql2/mysql2.bundle
   Reason: image not found - /Users/edwincaro/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/mysql2-0.4.5/lib/mysql2/mysql2.bundle
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/mysql2-0.4.5/lib/mysql2.rb:31:in `<top (required)>'
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `require'
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `each'
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `block in require'
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `each'
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `require'
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/bundler-1.6.2/lib/bundler.rb:132:in `require'
   from /Users/ec/Sites/ticketsys/config/application.rb:7:in `<top (required)>'
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
   from /Users/ec/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
   from bin/rails:4:in `require'
   from bin/rails:4:in `<main>'
   prompt$ 

I read all the 'Rails Server Error' posted previously here and tried most of the solution offered here but none of them worked for me.

I am thinking that maybe is the file dlopen what I am missing.

I will appreciate any help please


Solution

  • You need to reinstall your mysql library. Then:

    gem uninstall mysql2

    bundle install

    To rebuild the gem against the new mysql library