Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
809 views
Welcome To Ask or Share your Answers For Others

1 Answer

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'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...