Rails: how do I resolve the 'rake/rdoctask'' is deprecated' warning?

user2393462435 picture user2393462435 · Jan 2, 2012 · Viewed 8.3k times · Source

Just a forewarning: I'm a rails noob.

When I run:

rake db:migrate

I get this deprecation warning:

WARNING: 'require 'rake/rdoctask'' is deprecated.  Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
    at /Users/username/Code/rails/appname/rake/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rdoctask.rb

I'm using:

  • Rails 3.0.1
  • Rake 0.9.2.2
  • RSpec 2.0.1
  • RDoc 3.12

If I uninstall rake 0.9.2.2 and use 0.8.7 there's no warning, but I rather not count that as a solution.

After a google search, many sites say I need to update a line in my Rakefile (basically changing require ‘rake/rdoctask’ to require ‘rdoc/task’). However, my Rakefile looks like this:

require File.expand_path('../config/application', __FILE__)
require 'rake'

AppName::Application.load_tasks

There's no require statement to replace. When I add require 'rdoc/task', it has no effect. When I search the project for the deprecated 'rake/rdoctask', there are no results. So why is rails complaining?

edit: Not sure if it matters, but here's my gemfile:

source 'http://rubygems.org'

gem 'rails', '3.0.1'
gem 'sqlite3-ruby', :require => 'sqlite3'

group :development, :test do
   gem 'rspec-rails', '2.0.1'
   gem 'annotate-models', '1.0.4'
end

group :test do
   gem 'rspec', '2.0.1'
   gem 'webrat', '0.7.1'
   gem 'spork', '0.8.4'
end

Answer

Dave Newton picture Dave Newton · Jan 2, 2012

Note this is fixed in later Rails 3.0.x versions (e.g., Rails 3.0.9).

The fix isn't in the top-level Rakefile but rather in the file mentioned in the error; it's just a general purpose notification:

if Rake.application
  Rake.application.deprecate('require \'rake/rdoctask\'', 'require \'rdoc/task\' (in RDoc 2.4.2+)', __FILE__)
end

It's actually related to something else, though; see this.