Search code examples
rubyri

How to get the Ruby documentation from the command line


Is there a way to find out which part of my ri command that is not showing Ruby's documentation:

 $ ruby --version
 ruby 1.9.3p392 (2013-02-22 revision 39386) [i686-linux]

 $ ri --version
 ri 3.12.2     

 $ ri String
 Nothing known about String

When I use pry:

 $ pry --version
 Pry version 0.9.12 on Ruby 1.9.3

 $ pry 
 [1] pry(main)> ri String
 # shows String documentation
 [2] pry(main)> ri String.split
 error: 'String.split' not found
 [3] pry(main)> ri String.strip
 String.strip not found, maybe you meant:
 String#strip_heredoc

What should I do to make the documentation appear?


Solution

  • If you're using RVM to manage your Ruby installations you can do this:

    rvm docs generate
    

    If not, try doing this:

    gem install rdoc-data
    rdoc-data --install
    

    then try the ri command again.