ruby / irb

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

IRB crashes when started from ruby/debug session in Rails #1003

Closed dhh closed 1 month ago

dhh commented 2 months ago

With a new Rails app created from rails/main, IRB consistently crashes when invoked from a ruby/debug session started using debugger on Ruby 3.3.5. This is the error and backtrace:

(rdbg) irb    # command
irb_console = true                 # UI: Use IRB as the console (default: false)
>> #<Thread:0x000074c1d2f0d170@DEBUGGER__::SESSION@server /home/dhh/.local/share/mise/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/debug-1.9.2/lib/debug/session.rb:179 run> terminated with exception (report_on_exception is true):
/home/dhh/.local/share/mise/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/irb-1.14.0/lib/irb/debug.rb:72:in `block in setup': undefined method `call' for nil (NoMethodError)

            irb_output_modifier_proc.call(output, complete: complete)
                                    ^^^^^
        from /home/dhh/.local/share/mise/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/reline-0.5.10/lib/reline/line_editor.rb:783:in `modify_lines'
        from /home/dhh/.local/share/mise/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/reline-0.5.10/lib/reline/line_editor.rb:353:in `block in modified_lines'
        from /home/dhh/.local/share/mise/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/reline-0.5.10/lib/reline/line_editor.rb:346:in `with_cache'
        from /home/dhh/.local/share/mise/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/reline-0.5.10/lib/reline/line_editor.rb:352:in `modified_lines'
        from /home/dhh/.local/share/mise/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/reline-0.5.10/lib/reline/line_editor.rb:376:in `wrapped_prompt_and_input_lines'
        from /home/dhh/.local/share/mise/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/reline-0.5.10/lib/reline/line_editor.rb:441:in `wrapped_cursor_position'

Steps to reproduce:

rails new myapp
cd myapp
bin/rails generate scaffold message title:string
# edit app/controllers/messages_controller.rb and add "debugger" in the new action
bin/rails server
# Visit http://localhost:3000/messages/new
# Enter "irb" in the rdbg session that is started in the console

This is with debug 1.9.2, Ruby 3.3.5, and rails/main.

IRB does not crash if instead of debugger you start the IRB session using binding.irb. But that's not a replacement. Often it's useful to run in rdbg to use the full debugger, and only occasionally hoping into IRB.

st0012 commented 1 month ago

Closing as it's been fixed in #1006 and was released in v1.14.1.

dhh commented 1 month ago

Can confirm this is fixed. Thanks! 🙏