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?
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'
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With