Ruby-on-rails 没有要加载的文件 -- rdoc/task

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7826442/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:11:41  来源:igfitidea点击:

no such file to load -- rdoc/task

ruby-on-railsrubygemsrakerdoc

提问by Jarred

When I run

当我跑

rake db:create

I receive this error

我收到此错误

rake aborted!
no such file to load -- rdoc/task

(See full trace by running task with --trace)

Here is the --trace

这是 --trace

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/home/tpeg/rails_apps/Test/Rakefile:8
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:78:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:61:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2/bin/rake:32
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

I have rake 0.9.2 and rdoc 3.11 installed. I am running these commands in my app's directory.

我安装了 rake 0.9.2 和 rdoc 3.11。我在我的应用程序目录中运行这些命令。

回答by David

I had the same problem.

我有同样的问题。

I solved it by adding gem 'rdoc'to my Gemfile and then run bundle install.

我通过添加gem 'rdoc'到我的 Gemfile 来解决它,然后运行bundle install.

回答by Neal

If you're not using a Gemfile, it's likely that switching your line in your Rakefile from this:

如果你没有使用 Gemfile,很可能是从你的 Rakefile 中切换你的行:

require 'rake/rdoctask'

to this

对此

require 'rdoc/task'

will work. It did for me.

将工作。它对我有用。

Also try a

也试试

gem install rdoc

回答by Greg Benedict

You can actually trap for this in your Rakefile should you have different rake versions between environments. We are this way with older production applications.

如果环境之间有不同的 rake 版本,您实际上可以在 Rakefile 中为此设置陷阱。对于较旧的生产应用程序,我们采用这种方式。

begin
  require 'rake/rdoctask'
rescue
  require 'rdoc/task'
end

回答by Aghyad

If you're working on an app without a Gemfile (like a legacy with rails 2.3 --), you can install the gem rdoc manually:

如果您正在开发一个没有 Gemfile 的应用程序(例如带有 rails 2.3 -- 的旧版),您可以手动安装 gem rdoc:

gem install rdoc

gem 安装 rdoc