2

When I run rake db:migrate on Heroku, I get an error. I have no problems running it locally.

This works fine:

C:\unaton>rake db:migrate

But when I use

C:\unaton>heroku rake db:migrate

then I get the following error.

(in /app)
rake aborted!
uninitialized constant Rake::DSL
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:8:in `<class:Ta
skLib>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:6:in `<module:R
ake>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:3:in `<top (req
uired)>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/rdoctask.rb:20:in `<top (r
equired)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks/documentation.r
ake:1:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:15:in `block
 in <top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:6:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/tasks.rb:6:in `<top (
required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:214:in
 `initialize_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:139:in
 `load_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:77:in
`method_missing'
/app/Rakefile:7:in `<top (required)>'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `load'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/ruby1.9.2/bin/rake:31:in `<main>'

How do I fix this problem?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Deepak
  • 21
  • 4
  • 1
    look at http://stackoverflow.com/questions/6181312/how-to-fix-the-uninitialized-constant-rakedsl-problem-on-heroku – Casual Coder Jun 16 '11 at 18:38

2 Answers2

7

Either upgrade to rails 3.0.9 or add this to the Gemfile

gem "rake", "0.8.7"

eugen
  • 8,916
  • 11
  • 57
  • 65
  • I still ran into this problem with 3.0.9, and had to add "0.8.7" to the Gemfile. Also, you need to run "bundle update rake" after that to regenerate your Gemfile.lock, and push the new Gemfile.lock to heroku also. – Jan Hettich Jun 18 '11 at 23:18
  • This way works for me. Before this I have tried to [add `require 'rake/dsl_definition'`](http://stackoverflow.com/questions/6181312/how-to-fix-the-uninitialized-constant-rakedsl-problem-on-heroku) in my Rakefile but it didn't help. – William Notowidagdo Jun 21 '11 at 15:42
0

From http://softwaregravy.com/rake-not-backwards-compatible/

Here’s the error:

rake aborted! uninitialized constant Rake::DSL /usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in const_missing' /app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.1/lib/rake/tasklib.rb:8:in ' /app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.1/lib/rake/tasklib.rb:6:in `'

Pin rake to 0.8.7 in your Gemfile

gem 'rake', '0.8.7'

Note, you’re probably already locked into 0.9.X, so you need to do a:

bundle update rake

stephjang
  • 939
  • 1
  • 8
  • 13
  • The link is broken now ("The page you're looking for cannot be found"). – Peter Mortensen Oct 29 '11 at 11:35
  • Thanks for reporting this. But... the answer remains the same, and is essentially the same solution as the top answer. I just felt it necessary to attribute the author since it was quoted verbatim. – stephjang Dec 02 '11 at 08:07