Ruby-on-rails 错误:'rake/rdoctask' 已过时且不再受支持。改用“rdoc/task”(在 RDoc 2.4.2+ 中可用)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14117114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead
提问by DaveR
Seems the last post for this problem was closed for one reason or another so I'll try my luck...
似乎这个问题的最后一个帖子由于某种原因而被关闭,所以我会试试我的运气......
I'm trying to run a simple "rake db:migrate" command. When I do, I get the error in the title. Yes, the solution "appears" obvious but it's not because I don't my Rakefile does not contain any references to 'rake/rdoctask'. It seems to be coming from documentation.rake but when I try to change that file as recommended by the error, I get a different error. I have found a couple of posts declaring this to be a known issue but nothing I've found indicates how to fix or work around this.
我正在尝试运行一个简单的“rake db:migrate”命令。当我这样做时,我收到标题中的错误。是的,解决方案“看起来”很明显,但这并不是因为我的 Rakefile 不包含对“rake/rdoctask”的任何引用。它似乎来自documentation.rake,但是当我尝试按照错误建议更改该文件时,我收到了不同的错误。我发现有几篇帖子声明这是一个已知问题,但我发现没有任何内容表明如何修复或解决此问题。
Does anyone have any ideas how to fix it? Below is the output from the rake command with a --trace:
有没有人有任何想法如何解决它?以下是带有 --trace 的 rake 命令的输出:
$ rake --trace db:migrate
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/rdoctask.rb:1:in `<top (required)>'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/tasks/documentation.rake:2:in `require'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/tasks/documentation.rake:2:in `<top (required)>'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/tasks.rb:15:in `load'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/tasks.rb:15:in `block in <top (required)>'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/tasks.rb:6:in `each'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/tasks.rb:6:in `<top (required)>'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/application.rb:213:in `require'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/application.rb:213:in `initialize_tasks'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/application.rb:139:in `load_tasks'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
C:/developer/skknobara/Rakefile:7:in `<top (required)>'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load_rakefile'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:583:in `raw_load_rakefile'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:89:in `block in load_rakefile'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:88:in `load_rakefile'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:72:in `block in run'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
C:/Programs/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
C:/Programs/Ruby193/bin/rake:23:in `load'
C:/Programs/Ruby193/bin/rake:23:in `<main>'
I discovered that I had rails 3.0.3 in my Gemfile so I changed it to 3.2.9, but now when I run rake db:migrate I get:
我发现我的 Gemfile 中有 rails 3.0.3,所以我将其更改为 3.2.9,但是现在当我运行 rake db:migrate 时,我得到:
rake aborted!
Bundler could not find compatible versions for gem "rack":
In Gemfile:
rails (= 3.2.9) x86-mingw32 depends on
rack (~> 1.4.0) x86-mingw32
rack (1.2.5)
I'm not sure what the error means but "gem list rack" shows I have both 1.4.1 and 1.4.0 installed. My Gemfile is pretty simple:
我不确定错误是什么意思,但“gem list rack”显示我同时安装了 1.4.1 和 1.4.0。我的 Gemfile 非常简单:
gem 'rails', '3.2.9'
gem 'rack','< 1.4.1'
gem 'mysql2', '< 0.3'
Any thoughts?
有什么想法吗?
回答by Giridhar Bandi
I had similar problem using rails 2.3.5 so as instructed in the trace message I have edited the Rakefile to require 'rdoc/task' instead of rake/rdoctask and installed rdoc gem.
我在使用 rails 2.3.5 时遇到了类似的问题,因此按照跟踪消息中的指示,我编辑了 Rakefile 以需要 'rdoc/task' 而不是 rake/rdoctask 并安装了 rdoc gem。
If you are using rake version > 10.0.0 . please edit your Rakefile
如果您使用 rake 版本 > 10.0.0 。请编辑您的 Rakefile
from:
从:
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
to:
到:
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require 'tasks/rails'
If you don't want to edit the Rakefile you can switch back to older version of take like this
如果您不想编辑 Rakefile,您可以像这样切换回旧版本的 take
gem uninstall rake -v 10.0.3
gem install rake -v 0.8.7
回答by danijel
I ran into similar problem when migrating my old app to rails 2.3.15. I solved it by installing an older version of rake, and uninstalling current 10.0.3 version:
将旧应用程序迁移到 rails 2.3.15 时,我遇到了类似的问题。我通过安装旧版本的 rake 并卸载当前的 10.0.3 版本解决了这个问题:
gem install rake --version 0.8.7
gem uninstall rake --version 10.0.3
回答by James Testa
I got it to work by putting
我通过把它工作
gem 'rake', '0.9.2.2'
宝石'耙','0.9.2.2'
in my Gemfile and then running rake as
在我的 Gemfile 中,然后运行 rake 作为
bundle exec rake db:migrate
回答by Benjamin Atkin
I had to fix this while not breaking on places that have old rake but not rdoc installed. I added a begin...rescue clause:
我必须解决这个问题,同时不要破坏有旧耙子但没有安装 rdoc 的地方。我添加了一个开始...救援条款:
begin
require 'rake/rdoctask'
rescue
require 'rdoc/task'
end
回答by JstRoRR
I came across the same issue...I did what GiridharBandimentioned above:
我遇到了同样的问题......我做了上面提到的GiridharBandi:
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
to:
到:
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require 'tasks/rails'
Rake version 10.0.4 was there in the gem list but when I tried to uninstall, it said that rake is not installed. So I ignored this and proceeded to install rake 0.8.7. Once its installed, I installed rdoc
Rake 版本 10.0.4 在 gem 列表中,但是当我尝试卸载时,它说未安装 rake。所以我忽略了这一点并继续安装 rake 0.8.7。安装后,我安装了 rdoc
gem install rdoc
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
and then everything started working just fine.
然后一切都开始正常了。
For rails 3.0.6, with the same kind of error:
对于 rails 3.0.6,具有相同类型的错误:
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
I installed rake 0.9.2 and also rdoc. commented out the #require 'tasks/rails' and then everything started working. I think rake problem is resolved in rails > 3.2.9.
我安装了 rake 0.9.2 和 rdoc。注释掉#require 'tasks/rails',然后一切开始工作。我认为 rake 问题在 rails > 3.2.9 中得到解决。
回答by markussvensson
I had a similar problem recently.
我最近遇到了类似的问题。
Looks like the same problem as: Can't run any rake command: "ERROR: 'rake/rdoctask' is obsolete and no longer supported"
看起来与以下问题相同:无法运行任何 rake 命令:“错误:'rake/rdoctask' 已过时且不再受支持”
I solved it by upgrading to Rails 3.2.9.
我通过升级到 Rails 3.2.9 解决了这个问题。
回答by aferris
This probably isn't the right way to do this, but I went into my Gemfile.lock file and changed my rake version back from 10.0.3 to 0.8.7. I'm running Rails 3.0.5 right now, and had updated briefly to 3.0.19 before reverting back. I believe that updated some gems and also made it so that the Rails gem was looking for the newest version greater than or equal to 0.8.7:
这可能不是正确的方法,但我进入了我的 Gemfile.lock 文件并将我的 rake 版本从 10.0.3 改回了 0.8.7。我现在正在运行 Rails 3.0.5,并在恢复之前短暂更新到 3.0.19。我相信更新了一些 gems 并且还使 Rails gem 正在寻找大于或等于 0.8.7 的最新版本:
rails (3.0.5)
actionmailer (= 3.0.5)
actionpack (= 3.0.5)
activerecord (= 3.0.5)
activeresource (= 3.0.5)
activesupport (= 3.0.5)
bundler (~> 1.0)
railties (= 3.0.5)
railties (3.0.5)
actionpack (= 3.0.5)
activesupport (= 3.0.5)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
I also uninstalled 10.0.3:
我也卸载了 10.0.3:
gem uninstall rake --version 10.0.3
After that, everything is back to running as it should.
在那之后,一切都恢复正常运行。
If I didn't roll back rails 3.0.19, then I would have kept using rake 10.0.3.
如果我不回滚 rails 3.0.19,那么我会一直使用 rake 10.0.3。
Hope this helps someone!
希望这可以帮助某人!
回答by mcr
Like the original poster, I don't have a require of rake/rdoctask. Upgrading my rails is not an option. The answer is to keep your rake at 0.9.2.2 in your Gemfile.
像原始海报一样,我不需要 rake/rdoctask。升级我的导轨不是一种选择。答案是将 Gemfile 中的佣金保持在 0.9.2.2。
回答by L2G
I run into this whenever I have a Bundler-based project and I'm using Ruby 1.9.2. Eventually I figure out that Bundler isn't managing the rdoc gem, and all I have to do to fix the problem is include rdoc in the Gemfile (or the gemspec if Gemfile is already configured to use it) and run bundle install.
每当我有一个基于 Bundler 的项目并且我使用的是 Ruby 1.9 时,我就会遇到这个问题。2. 最终我发现 Bundler 没有管理 rdoc gem,我需要做的就是在 Gemfile 中包含 rdoc(或者 gemspec,如果 Gemfile 已经配置为使用它)并运行bundle install.
I never seem to run into this with 1.9.3 or 2.0.0, only 1.9.2.
我似乎从来没有遇到过 1.9.3 或 2.0.0,只有 1.9.2。
回答by Redrick
Oh my god, I was figting with this for almost hour and finally here is my case (may help someone :) ): I got myself multiple rails versions installed so I just uninstalled the latest one as I want to use the most edgy one (the 4.0.1 for now)
哦,天哪,我花了将近一个小时来解决这个问题,最后这是我的情况(可能对某人有帮助:)):我安装了多个 Rails 版本,所以我只是卸载了最新版本,因为我想使用最前卫的版本(现在是 4.0.1)
so :
所以 :
$ gem uninstall rails
and I got this:
我得到了这个:
Select gem to uninstall:
1. rails-0.9.5
2. rails-4.0.0
3. rails-4.0.1
4. All versions
>
so I selected first two and that was it :) now everything is OK hope this helps someone who got mysteriously stuck as me :(
所以我选择了前两个,就是这样:) 现在一切正常,希望这能帮助那些像我一样被神秘卡住的人:(

