Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid raising errors while running help for custom commands #944

Merged
merged 3 commits into from
May 3, 2024
Merged

Avoid raising errors while running help for custom commands #944

merged 3 commits into from
May 3, 2024

Conversation

kachick
Copy link
Member

@kachick kachick commented May 3, 2024

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
Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

Thanks 👍

test/irb/command/test_custom_command.rb Outdated Show resolved Hide 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
30 checks passed
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
Copy link
Member Author

kachick commented May 4, 2024

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
Development

Successfully merging this pull request may close these issues.

2 participants