Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rake aborted! Uninitialized constant Rake::DSL on Heroku

When trying to rake db:migrate on Heroku. I'm getting the following error.

rake aborted!
uninitialized constant Rake::DSL

From what I've gathered this seems to be a bug with Rake 0.9.2. If I do "gem list" locally only Rake (0.8.7) appears to be installed.

I've tried adding "gem 'rake', '0.8.7'" to my gem file and running bundle install but then I get the following error.

You have requested:
rake = 0.8.7

The bundle currently has rake locked at 0.9.2.
Try running `bundle update rake`

If I do run bundle update rake, it reverts back to 0.9.2, and I'm back where I started.

Am I missing something obvious here?

like image 377
Jon Avatar asked Jul 18 '11 01:07

Jon


2 Answers

You should run commands with bundle exec to ensure your getting the proper dependencies. So run:

bundle exec rake db:migrate

For a more detailed post see Yehuda Katz blog post http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/

If you still continue to have problems there appears to be several other people with the same issue How to fix the uninitialized constant Rake::DSL problem on Heroku? which they resolved by adding the following to their Rakefile:

require 'rake/dsl_definition'
require 'rake'
like image 138
JDutil Avatar answered Oct 17 '22 22:10

JDutil


I got this error when doing "heroku rake db:migrate".

In /app:

rake aborted!
uninitialized constant Rake::DSL
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in `const_missing'
....
...
....
..
etc...

I fixed it by adding

require 'rake/dsl_definition' 

in RakeFile and then typed in

bundle update rake
git add .
git commit -m "Change RakeFile"
git push heroku
heroku rake db:migrate

This one solved my problem. I didn't add gem 'rake', '0.8.7' in my gem file and my gem list shows rake (0.9.2, 0.8.7).

like image 3
hlim Avatar answered Oct 18 '22 00:10

hlim