Home Ask Login Register

Developers Planet

Your answer is one click away!

Honorable Sanders February 2016

Cannot load mysql2 gem

I've already seen some different answers, but none of these helped me...

This is the trick: I have to fix this without touching the Gemfile. I'm currently creating my working environment so that it matches the production server, so, I cannot modify the rails' code at all.

My OS: OSX 10.11

Ruby: ruby 2.0.0p643

Rails: 4.0.0

The gem is the Gemfile as gem 'mysql2'. There are no errors when doing bundle install, but when I try to rake db:migrate --trace this is the output:

rake aborted!
There was an error while trying to load the gem 'mysql2'.
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
/Users/redar/redar/config/application.rb:7:in `<top (required)>'
/Users/redar/redar/Rakefile:4:in `require'
/Users/redar/redar/Rakefile:4:in `<top (required)>'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'


AndyV February 2016


bundle exec rake db:migrate

This will make sure that you are executing "rake db:migrate" with the gems listed in the Gemfile loaded and available. If you run it without "bundle exec" you may be executing only with the system gems available.

Post Status

Asked in February 2016
Viewed 3,997 times
Voted 6
Answered 1 times


Leave an answer

Quote of the day: live life