19
votes

Deploying a Rails3 app, and am having some issues getting rake to find the gems installed by 'bundle install --deployment':

$ rake db:migrate
(in /home/jrdev/rails/testapp)
rake aborted!
!!! Missing the mysql2 gem. Add it to your Gemfile: gem ‘mysql2’

But, that gem in is the Gemfile, and is also in the vendor/bundle folder…

$ bundle show mysql2
/home/jrdev/rails/testapp/vendor/bundle/ruby/1.8/gems/mysql2-0.2.6

My .gemrc file:

gemhome: /home/jrdev/.gems
gempath:
- /home/jrdev/.gems
- /usr/lib/ruby/gems/1.8

I thought rails3 apps already had the bundler code to detect which gems to use? I know I'm using the right rake, too (rake db:migrate --trace starts in /home/jrdev/rails/testapp/vendor/bundle/ruby/1.8/bin/rake). Same result using bundler's exec.

:(

2

2 Answers

50
votes

Wouldn't you freaking know I solve it a minute after asking.

My database.yml file was still calling the 'mysql' adapter instead of 'mysql2'.

Still, what an OBSCURE error message!

0
votes

In /home/jrdev/rails/testapp, you should find a file called Gemfile. Look into it and just add the line

gem 'mysql2'

somewhere.