Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
      end
    end
    
  • 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.


All I needed to do was use:

gem install rake

I had version 0.9.2 already, just needed installing.


Reinstall the rake gem and it should work fine:

gem uninstall rake -v=0.9.2 
gem install rake -v=0.9.2

If not, specify version '0.8.7' in your Gemfile.


If not using Bundler:

sudo gem install rake -v 0.8.7
sudo gem uninstall rake

Then choose to uninstall 0.9.0.