Ruby on Rails and Rake problems: uninitialized constant Rake::DSL Ruby on Rails and Rake problems: uninitialized constant Rake::DSL ruby-on-rails ruby-on-rails

Ruby on Rails and Rake problems: uninitialized constant Rake::DSL


A tweet from DHH earlier. Rake .9.0 breaks Rails and several other things, you need to:

gem "rake", "0.8.7"

in your Gemfile.


I made some research just after my previous answer (sorry, I must do before it).

All problems are solved with Rake gem 0.9.2.. I followed these steps:

  • I installed gem install rake -v=0.9.2 (I had the 0.9.1 gem)
  • removed the 0.9.1 with gem uninstall rake -v=0.9.1
  • updated with bundle update
  • then the db:migrate showed a warning, WARNING: Global access to Rake DSL methods is deprecated. Please....

    It was solved by adding the following to the Rake file.

    module ::YourApplicationName    class Application    include Rake::DSL  endend
  • I ommited the module ::RakeFileUtils extend Rake::FileUtilsExtend option sugested by @databyte.

It means that the Rake gem 0.9.2 works fine!


Going through Chapter 2 of Railstutorial (demo_app) and ran into this problem. I tried all of the other answers listed here, but couldn't get it to work until I did this:

Put this in your Rakefile above require 'rake':

require 'rake/dsl_definition'

via How to fix the uninitialized constant Rake::DSL problem on Heroku?

I also recommitted and pushed all files to Github and Heroku.