Search code examples
ruby

Undefined method for ri inside of IRB


Inside of the interactive ruby console if i type ri then i get an undefined method error, do i explicitly have to install documentation somewhere to get this to work?

irb(main):015:0* ri --help
NoMethodError: undefined method `-@' for nil:NilClass
    from (irb):15
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:295
irb(main):016:0> ri Array
NoMethodError: undefined method `ri' for main:Object
    from (irb):16
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:295

Solution

  • You probably do not want to do that. What you should be doing is exiting to the shell (or preferably, open a new terminal tab or screen session) and running ri separately, which is a program, from there. If you really, really, want to do what you're doing, you can always use backticks to run ri --help, or any other shell command.

    irb(main):015:0* `ri --help`