Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global access to Rake DSL methods is deprecated

I am working through the Ruby on Rails 3 tutorial book and typed the following on the command line:

rake db:migrate 

which produced the following warning.

WARNING: Global access to Rake DSL methods is deprecated.  Please Include     ...  Rake::DSL into classes and modules which use the Rake DSL methods.  WARNING: DSL method DemoApp::Application#task called at /Users/imac/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks' 

I am not sure what to do about it or how to work with it. I don't know any other command for Rake.

How can I fix this problem?

like image 665
chell Avatar asked Jun 01 '11 09:06

chell


2 Answers

Adding include Rake::DSL to the Rakefile before the applications load_tasks were called also worked for me.

So in the above user's case before the DemoApp::Application.load_tasks in the Rakefile.

like image 196
Patelify Avatar answered Oct 10 '22 20:10

Patelify


I found this in Stack Overflow question Ruby on Rails and Rake problems: uninitialized constant Rake::DSL. It refers to a @DHH tweet.

Put the following in your Gemfile

gem "rake", "0.8.7" 

You may see something like

rake aborted! You have already activated Rake 0.9.1 ... 

I still had a copy of Rake 0.9.1 in my directory so I deleted it.

You can "delete" Rake 0.9.1 by running the following command:

gem uninstall rake -v=0.9.1 

If you have multiple versions of the gem installed, you'll be prompted to pick a version.

After 0.9.1 was cleaned out, I ran

bundle update rake 

and was finally able to create my database files. I was using rake db:create, but it should work for rake db:migrate as well.

I hope it helps.

like image 22
Brian Bruijn Avatar answered Oct 10 '22 20:10

Brian Bruijn