`require': 无法加载这样的文件 -- rdoc/usage (LoadError)

`require': cannot load such file -- rdoc/usage (LoadError)

我在运行我的脚本中遇到这个错误:

`require': cannot load such file -- rdoc/usage (LoadError)

来自

/Users/S/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rdoc/usage (LoadError)
from /Users/S/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from pdf.rb:34:in `<main>'

我的 Gemfile 中有 rdoc

gem 'rdoc', '~> 4.2.2'

我也尝试过不指定版本。在我的脚本中,我需要 gems 和 rdoc/usage:

require 'rubygems'
require 'rdoc/usage'

我有 运行 gem 安装 rdoc

Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 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!
Successfully installed rdoc-4.2.2

而且我运行宁 ruby 2.2.2 应该不需要安装 ruby roc/ri 数据。 (我试了亏,果然没有效果)。

非常感谢任何帮助,谢谢。

旧的 rdoc/usage 模块很久以前就从 rdoc 中删除了,即在 Ruby 1.9.1 中(当时 rdoc 仍然是 Ruby 核心语言的一部分)。参见 https://bugs.ruby-lang.org/issues/2713 for a discussion or the SVN commit

因此,对于最近的 Rubies,无法再使用此模块。您应该更新代码以使用替代方法生成文档。