Chris Steinbach
Chris Steinbach

Reputation: 118

Generating docs for ruby 2.5

Having installed ruby 2.5 on Ubuntu 18.04 I tried using the ri command with the following result:

$ ri String
Nothing known about String

In answer to similar questions, the advice is offered to:

1. Generate the documentation using the rvm command

$ rvm docs generate

I didn't install using rvm, so I imagine this option is closed to me.

2. Generate documentation for installed gems

$ gem rdoc --all --ri --no-rdoc

This gave the following error messages:

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. Use rdoc-data --install

$ gem install rdoc-data
$ rdoc-data --install

This returned the error message:

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

Perhaps this installed an obsolete version of the rdoc-data gem? If so, is there some way to fix that?

4. Generate docs from source

$ tar xvfz ~/Downloads/ruby-2_5_4.tar.gz
$ cd ruby-2_5_4
$ rdoc --all --ri

This gives the error:

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)

And indeed, the exe directory contains the file rdoc2.5 and not plain rdoc.

So. Where to go from here?

Upvotes: 3

Views: 338

Answers (1)

Chris Steinbach
Chris Steinbach

Reputation: 118

As is so often the case, documenting in full what I had already tried showed a way forward, and the error message of attempt number four made me wonder whether and rdoc2.5 was available in the path, which is was.

The following worked for me:

$ 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

Although I'm only able to see the documentation using the ri2.5 command. The regular ri command returns a different error that suggests I may have broken something with one of these experimental solutions:

$ 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)

This makes me wonder whether my ruby installation is as clean as it ought to be. The dpkg command reports the following ruby packages as installed:

$ 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

Perhaps it would be best to reinstall everything ruby related from scratch?


Update: I removed everything ruby related, and manually removed a couple of commands lingering in /usr/local/bin (ri and rdoc). I reinstalled using apt install ruby and everything seems fine. The docs are generated and available after installation.

Upvotes: 1

Related Questions