ruby / irb

interactive Ruby
BSD 2-Clause "Simplified" License
392 stars 119 forks source link

Avoid raising errors while running help for custom commands #944

Closed kachick closed 6 months ago

kachick commented 6 months ago

When I updating my custom command with irb 1.13.0, I have faced this error

irb(main):001> help my_command
/home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb/pager.rb:57:in `content_exceeds_screen_height?': undefined method `lines' for nil (NoMethodError)

        content.lines.count > pageable_height ||
               ^^^^^^
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb/pager.rb:11:in `page_content'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb/command/help.rb:20:in `execute'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb/command/base.rb:42:in `execute'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb/context.rb:598:in `evaluate'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb.rb:1043:in `block (2 levels) in eval_input'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb.rb:1374:in `signal_status'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb.rb:1035:in `block in eval_input'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb.rb:1114:in `block in each_top_level_statement'
        from <internal:kernel>:187:in `loop'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb.rb:1111:in `each_top_level_statement'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb.rb:1034:in `eval_input'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb.rb:1015:in `block in run'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb.rb:1014:in `catch'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb.rb:1014:in `run'
        from /home/kachick/.local/share/gem/ruby/3.3.0/gems/irb-1.13.0/lib/irb.rb:901:in `start'
        from ./bin/console:5:in `<main>'
Maybe IRB bug!

The output from the my_command does not define meta attributes, but displaying Maybe IRB bug! is not correct even in this case.

kachick commented 6 months ago

Thank you!