在Ubuntu 18.04上安装了ruby 2.5,我尝试使用ri
命令,结果如下:
$ ri String
Nothing known about String
为回答similar questions,建议提供给:
1。使用rvm命令生成文档
$ rvm docs generate
我不是使用rvm
安装的,所以我想这个选项对我来说是关闭的。
2。生成已安装宝石的文档
$ gem rdoc --all --ri --no-rdoc
这给出了以下错误消息:
ERROR: Unable to document did_you_mean-1.2.0, /usr/share/rubygems-integration/all/gems/did_you_mean-1.2.0 is missing, skipping
ERROR: Unable to document minitest-5.10.3, /usr/share/rubygems-integration/all/gems/minitest-5.10.3 is missing, skipping
ERROR: Unable to document net-telnet-0.1.1, /usr/share/rubygems-integration/all/gems/net-telnet-0.1.1 is missing, skipping
ERROR: Unable to document power_assert-0.2.7, /usr/share/rubygems-integration/all/gems/power_assert-0.2.7 is missing, skipping
ERROR: Unable to document rake-12.3.1, /usr/share/rubygems-integration/all/gems/rake-12.3.1 is missing, skipping
Parsing documentation for rdoc-4.3.0
Parsing documentation for rdoc-data-4.1.0
ERROR: Unable to document test-unit-3.2.5, /usr/share/rubygems-integration/all/gems/test-unit-3.2.5 is missing, skipping
3。使用rdoc-data --install
$ gem install rdoc-data
$ rdoc-data --install
这返回了错误消息:
NOTE: Gem.datadir is deprecated; use spec.datadir instead. It will be removed on or after 2016-10-01.
Gem.datadir called from /var/lib/gems/2.5.0/gems/rdoc-data-4.1.0/lib/rdoc/data.rb:50.
Your ruby version 2.5 is not supported, only 1.8, 1.9, 2.0, 2.1, 2.2, 2.3
也许这安装了rdoc-data
gem的过时版本?如果是这样,有什么办法可以解决这个问题?
4。从来源生成文档
$ tar xvfz ~/Downloads/ruby-2_5_4.tar.gz
$ cd ruby-2_5_4
$ rdoc --all --ri
出现错误:
Traceback (most recent call last):
1: from /usr/local/bin/rdoc:23:in `<main>'
/usr/local/bin/rdoc:23:in `load': cannot load such file -- /usr/lib/ruby/gems/2.5.0/gems/rdoc-6.0.1/exe/rdoc (LoadError)
确实,exe目录包含文件rdoc2.5
而不是普通的rdoc
。
所以。从这里去哪里?
答案 0 :(得分:0)
通常情况下,完整记录我已经尝试过的内容表明了前进的道路,而第四次尝试的错误消息让我想知道路径中是否有rdoc2.5和rdoc2.5。 / p>
以下对我有用:
$ rdoc2.5 --all --ri
Parsing sources...
100% [831/831] vsnprintf.c
Generating RI format into /home/christians/.rdoc...
Files: 831
Classes: 1324 ( 565 undocumented)
Modules: 284 ( 121 undocumented)
Constants: 1313 ( 526 undocumented)
Attributes: 1066 ( 251 undocumented)
Methods: 10078 (2161 undocumented)
Total: 14065 (3624 undocumented)
74.23% documented
Elapsed: 26.8s
尽管我只能使用ri2.5命令查看文档。常规ri命令返回一个不同的错误,表明我可能使用以下实验解决方法之一破坏了某些东西:
$ ri String
Traceback (most recent call last):
1: from /usr/local/bin/ri:23:in `<main>'
/usr/local/bin/ri:23:in `load': cannot load such file -- /usr/lib/ruby/gems/2.5.0/gems/rdoc-6.0.1/exe/ri (LoadError)
这使我想知道我的红宝石安装是否应达到应有的清洁程度。 dpkg命令报告以下已安装的ruby软件包:
$ dpkg -l | grep ruby
ii libruby2.5:amd64 2.5.1-1ubuntu1.2 amd64 Libraries necessary to run Ruby 2.5
ii rake 12.3.1-1 all ruby make-like utility
ii ruby 1:2.5.1 amd64 Interpreter of object-oriented scripting language Ruby (default version)
ii ruby-did-you-mean 1.2.0-2 all smart error messages for Ruby > 2.3
ii ruby-minitest 5.10.3-1 all Ruby test tools supporting TDD, BDD, mocking, and benchmarking
ii ruby-net-telnet 0.1.1-2 all telnet client library
ii ruby-power-assert 0.3.0-1 all library showing values of variables and method calls in an expression
ii ruby-test-unit 3.2.5-1 all unit testing framework for Ruby
ii ruby2.5 2.5.1-1ubuntu1.2 amd64 Interpreter of object-oriented scripting language Ruby
ii rubygems-integration 1.11 all integration of Debian Ruby packages with Rubygems
也许最好重新安装所有与红宝石相关的东西?
更新:我删除了所有与ruby相关的内容,并手动删除了在/ usr / local / bin(ri和rdoc)中徘徊的几个命令。我使用apt install ruby重新安装,一切似乎都很好。这些文档将在安装后生成并可用。