ruby/irb

Bug when ctrl-c in pager

dorianmariecom opened this issue · 3 comments

Description

I was paging through a large array and hit ctrl-c.

I was expecting to go back to the irb session.

I got an error

Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb/pager.rb:36:in `kill': No such process (Errno::ESRCH)
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb/pager.rb:36:in `rescue in page'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb/pager.rb:20:in `page'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb/pager.rb:12:in `page_content'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1357:in `output_value'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1013:in `block (2 levels) in eval_input'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1317:in `signal_status'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:998:in `block in eval_input'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1080:in `block in each_top_level_statement'
	from <internal:kernel>:187:in `loop'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1075:in `each_top_level_statement'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:997:in `eval_input'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:984:in `block in run'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:983:in `catch'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:983:in `run'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1541:in `irb'
	from <internal:prelude>:5:in `irb'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/dorian-pretty-0.1.0/bin/pretty:81:in `rescue in block in <top (required)>'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/dorian-pretty-0.1.0/bin/pretty:75:in `block in <top (required)>'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/dorian-pretty-0.1.0/bin/pretty:74:in `select'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/dorian-pretty-0.1.0/bin/pretty:74:in `<top (required)>'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/bin/pretty:25:in `load'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/bin/pretty:25:in `<main>'
/Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:897:in `raise': abort then interrupt! (IRB::Abort)
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:897:in `irb_abort'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1300:in `signal_handle'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:979:in `block in run'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb/pager.rb:13:in `write'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb/pager.rb:13:in `puts'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb/pager.rb:13:in `block in page_content'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb/pager.rb:24:in `page'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb/pager.rb:12:in `page_content'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1357:in `output_value'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1013:in `block (2 levels) in eval_input'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1317:in `signal_status'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:998:in `block in eval_input'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1080:in `block in each_top_level_statement'
	from <internal:kernel>:187:in `loop'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1075:in `each_top_level_statement'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:997:in `eval_input'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:984:in `block in run'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:983:in `catch'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:983:in `run'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/irb-1.11.1/lib/irb.rb:1541:in `irb'
	from <internal:prelude>:5:in `irb'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/dorian-pretty-0.1.0/bin/pretty:81:in `rescue in block in <top (required)>'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/dorian-pretty-0.1.0/bin/pretty:75:in `block in <top (required)>'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/dorian-pretty-0.1.0/bin/pretty:74:in `select'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/dorian-pretty-0.1.0/bin/pretty:74:in `<top (required)>'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/bin/pretty:25:in `load'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/bin/pretty:25:in `<main>'
/Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/dorian-pretty-0.1.0/bin/pretty:78:in `block in <top (required)>': invalid byte sequence in UTF-8 (ArgumentError)
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/dorian-pretty-0.1.0/bin/pretty:74:in `select'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/dorian-pretty-0.1.0/bin/pretty:74:in `<top (required)>'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/bin/pretty:25:in `load'
	from /Users/dorianmariefr/.asdf/installs/ruby/3.3.0/bin/pretty:25:in `<main>'
Maybe IRB bug!

Result of irb_info

Ruby version: 3.3.0
IRB version: irb 1.11.1 (2024-01-08)
InputMethod: RelineInputMethod with Reline 0.4.2
Completion: Autocomplete, RegexpCompletor
.irbrc path: /Users/dorianmariefr/.irbrc
RUBY_PLATFORM: arm64-darwin23
East Asian Ambiguous Width: 1

Terminal Emulator

Terminal.app in macOS with fish

Setting Files

My config was commented out

st0012 commented

@dorianmariefr Thanks for reporting. Does this always happen when you Ctrl-c in a pager, or intermittently, or only when paging certain content? Asking because I can't reproduce it myself, so more information will help a lot.

tompng commented

Reproduced by

irb(main):001> 20000.times.to_a

then type \C-c and q

with PAGER=less less --version #=> less 581.2 (POSIX regular expressions)
To reproduce, the output bytes passed to pager should be large enough. (>= 72*1024+1 bytes in my environment)
Maybe related to pager's read buffer size, I guess.

Thanks ❤️