Skip to content

Exception when using irb:rdbg where objectto_s might return nil #1089

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

Open
adam12 opened this issue Apr 7, 2025 · 0 comments
Open

Exception when using irb:rdbg where objectto_s might return nil #1089

adam12 opened this issue Apr 7, 2025 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@adam12
Copy link
Contributor

adam12 commented Apr 7, 2025

The to_s method returning nil is obviously an issue, but we should guard against that anyways.

# test.rb
class SomeObject
  def to_s
    nil
  end

  def do_something
    debugger
  end
end

SomeObject.new.do_something
$ rdbg -e 'config set irb_console 1 ;; c' -c ruby test.rb
/Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:601:in 'IRB::Irb#truncate_prompt_main': undefined method 'tr' for nil (NoMethodError)

      str = str.tr(CONTROL_CHARACTERS_PATTERN, ' ')
               ^^^
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:616:in 'block in IRB::Irb#format_prompt'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:610:in 'String#gsub'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:610:in 'IRB::Irb#format_prompt'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:585:in 'IRB::Irb#generate_prompt'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:242:in 'IRB::Irb#readmultiline'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:270:in 'block in IRB::Irb#each_top_level_statement'
        from <internal:kernel>:168:in 'Kernel#loop'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:269:in 'IRB::Irb#each_top_level_statement'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:192:in 'IRB::Irb#eval_input'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:130:in 'block in IRB::Irb#debug_readline'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:123:in 'Kernel#catch'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb.rb:123:in 'IRB::Irb#debug_readline'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb/debug/ui.rb:57:in 'block in IRB::Debug::UI#readline'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb/debug/ui.rb:76:in 'block in IRB::Debug::UI#setup_interrupt'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/session.rb:1989:in 'DEBUGGER__::Session#intercept_trap_sigint'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb/debug/ui.rb:69:in 'IRB::Debug::UI#setup_interrupt'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/irb-1.15.2/lib/irb/debug/ui.rb:55:in 'IRB::Debug::UI#readline'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/session.rb:445:in 'DEBUGGER__::Session#wait_command'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/session.rb:405:in 'block in DEBUGGER__::Session#wait_command_loop'
        from <internal:kernel>:168:in 'Kernel#loop'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/session.rb:404:in 'DEBUGGER__::Session#wait_command_loop'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/session.rb:330:in 'DEBUGGER__::Session#process_event'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/session.rb:255:in 'DEBUGGER__::Session#session_server_main'
        from /Users/adam/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/debug-1.10.0/lib/debug/session.rb:207:in 'block in DEBUGGER__::Session#activate'
@st0012 st0012 added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Development

No branches or pull requests

2 participants