ERROR: 'rake/rdoctask' is obsolete and no longer supported

醉酒当歌 提交于 2019-12-01 13:09:29

Just to help anyone else who has had this hassle. If you are like me, then your problem is that the current version of rails is 4 and you are wanting to use an older version like 3.0.7

If you install rails fresh to learn it ,say, and the tutorial you are using is for a 3.0.x version of rails OR your job requires the use of the older version of rails.. then you can get into this hole.

In my case I got a 3.0.7 rails project dumped on me and was told to learn rails and make some enhancements to this code.

so, I just started learning rails and was following the tutorial until I got this error when doing a 'rake db:migrate'

rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks/documentation.rake:1:in `require'
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks/documentation.rake:1:in `<top (required)>'
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks.rb:15:in `load'
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks.rb:15:in `block in <top (required)>'

This happened cos I was using an older version of rails.. in my case 3.0.7 If you run a 'bundle show', like I did then, you may see that you are using the rake version 10.0.0 or something like that...and you need to be running rake 0.9.2 ... which is where the problem is coming from..

The solution for me was to (a) add a gem to my gemfile and (b) to a bundle install

So, in my gemfile I added:

gem 'rake', '0.9.2'

Then did a

'bundle install'

Got this message:

You have requested:
  rake = 0.9.2

The bundle currently has rake locked at 10.1.0.
Try running `bundle update rake`

And so I did that...

bundle update rake.

And that went fine.

then when I did the'rake db:migrate' it just worked.

Hope this helps somebody. Vida.

PS: if you are new to rails, like me, and you inherit an older rails app then for gods sake NEVER run 'bundle update' or you will enter a world of pain. That command updates all your gems to the very latest versions and you end up with a load of problems with incompatibilities. The only way out of it is if you are lucky enough to have git installed and can do a 'git checkout' to go back...

I struck with this same problem when try to install gems by the command rake gems:install my rails version is rails2.3.2 and i have rvm installed. my gem list is,

actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
bundler (1.3.5)
rails (2.3.2)
rake (10.0.4)
rubygems-bundler (1.1.1)
rvm (1.11.3.7)

so uninstalled the rake by the command

rvm use ruby-1.8.7-p371@global && gem uninstall rake -v 10.0.4

then i installed rake of older version

rvm use ruby-1.8.7-p371@global && gem install rake -v 0.8.7

now rake gems:install works fine

hope it may help some one!

Upgrading to rails 4.0.0 I got the same error.

rails -v
(in /Users/oma/.rvm/gems/ruby-2.0.0-p247/gems/rails-0.9.5)
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/Users/oma/.rvm/gems/ruby-2.0.0-p247/gems/rails-0.9.5/Rakefile:3:in `<top (required)>'
(See full trace by running task with --trace)

To upgrade, I removed the version number in Gemfile

 source 'https://rubygems.org'
 gem 'rails'   # NO VERSION

and did bundle update as I thought this would pick the last. But somehow, I got rails 0.9.5. It feels like some practical joke, really, lol

$ gem list rails
rails (4.0.1.rc2, 4.0.0, 0.9.5)

I can't tell you with 100% certainty that this was the cause, but we were two people, working on the same branch and seeing the same error. The fix worked for both of us. Simply

specify rails version!

$gem uninstall rails -v 0.9.5
Gemfile
  source 'https://rubygems.org'
  gem 'rails', '4.0.0'

then bundle, run rails -v, giggle (or cry) and get back to producing

Andriy Samilyak

Take a look at similar problem solution on StackOverflow

Another option is to use (example taken from Redmine Rakefile)

require 'rdoc'
require 'rdoc/task'

Instead of

require 'rake/testtask'
require 'rake/rdoctask'

The following works for me using ruby 1.9.3p448 (2013-06-27 revision 41675):

1) Use rake version 10.1.0 (put following in your Gemfile):

gem 'rake', '10.1.0'

(Note you can likely use another version, but the line number below might change.)

2) Comment line 54 of your Rakefile and replace it as follows:

#require 'rake/rdoctask'
gem 'rdoc', ">= 2.4.2"
require 'rdoc/task'

3) Test

$ bundle install
$ bundle exec rake
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!