Skip to content

Avoid raising errors while running help for custom commands - #944

Merged
st0012 merged 3 commits into
ruby:masterfrom
kachick:fix-no-meta-commands
May 3, 2024
Merged

st0012 merged 3 commits into
ruby:masterfrom
kachick:fix-no-meta-commands

Conversation

@kachick

@kachick kachick commented May 3, 2024

Copy link
Copy Markdown
Member

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.

Raising an error from the help command is not a pleasure for the
end user, even if the command does not define any attributes

@st0012 st0012 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

Comment thread test/irb/command/test_custom_command.rb Resolved
@st0012 st0012 added the bug Something isn't working label May 3, 2024
@st0012
st0012 merged commit c8bba9f into ruby:master May 3, 2024
matzbot pushed a commit to ruby/ruby that referenced this pull request May 3, 2024
commands
(ruby/irb#944)

* Avoid raising errors while running help for custom commands

Raising an error from the help command is not a pleasure for the
end user, even if the command does not define any attributes

* Update test/irb/command/test_custom_command.rb

---------

ruby/irb@c8bba9f8dc

Co-authored-by: Stan Lo <stan001212@gmail.com>
@kachick

kachick commented May 4, 2024

Copy link
Copy Markdown
Member Author

Thank you!

@kachick
kachick deleted the fix-no-meta-commands branch May 4, 2024 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants