Skip to content

IRB crashes when typing %ww #162

@pocke

Description

@pocke

Description

IRB crashes when I type %ww, but I expect it doesn't crash.

Reproduce

  1. Launch irb command from a shell
    • I launched irb with RUBYOPT='-I path/to/reline/lib -I path/to/irb/lib' irb to use the HEAD of them.
  2. Type %ww.
    • I can reproduce other alpha-numeric characters, such as %aa or %11.
  3. It crashes.

Sometimes it doesn't crash on %ww (double w), but it always crashes on %www (triple w).

The stacktrace is here

irb(main):001:0> %w/home/pocke/ghq/github.com/ruby/reline/lib/reline/unicode.rb:124:in `calculate_width': undefined method `encode' for nil:NilClass (NoMethodError)
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline/line_editor.rb:1316:in `calculate_width'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline/line_editor.rb:126:in `check_multiline_prompt'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline/line_editor.rb:365:in `rerender'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline.rb:248:in `block (3 levels) in inner_readline'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline.rb:246:in `each'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline.rb:246:in `block (2 levels) in inner_readline'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline.rb:330:in `block in read_io'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline.rb:284:in `loop'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline.rb:284:in `read_io'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline.rb:245:in `block in inner_readline'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline.rb:243:in `loop'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline.rb:243:in `inner_readline'
        from /home/pocke/ghq/github.com/ruby/reline/lib/reline.rb:175:in `readmultiline'
        from /home/pocke/.rbenv/versions/trunk/lib/ruby/3.1.0/forwardable.rb:238:in `readmultiline'
        from /home/pocke/.rbenv/versions/trunk/lib/ruby/3.1.0/forwardable.rb:238:in `readmultiline'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb/input-method.rb:302:in `gets'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb.rb:519:in `block (2 levels) in eval_input'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb.rb:745:in `signal_status'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb.rb:518:in `block in eval_input'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb/ruby-lex.rb:203:in `lex'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb/ruby-lex.rb:175:in `block (2 levels) in each_top_level_statement'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb/ruby-lex.rb:172:in `loop'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb/ruby-lex.rb:172:in `block in each_top_level_statement'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb/ruby-lex.rb:171:in `catch'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb/ruby-lex.rb:171:in `each_top_level_statement'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb.rb:537:in `eval_input'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb.rb:472:in `block in run'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb.rb:471:in `catch'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb.rb:471:in `run'
        from /home/pocke/ghq/github.com/ruby/irb/lib/irb.rb:400:in `start'
        from /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/3.1.0/gems/irb-1.3.0/exe/irb:11:in `<top (required)>'
        from /home/pocke/.rbenv/versions/trunk/bin/irb:23:in `load'
        from /home/pocke/.rbenv/versions/trunk/bin/irb:23:in `<main>'

Result of irb_info

irb(main):001:0> irb_info
=> 
Ruby version: 3.1.0
IRB version: irb 1.3.0 (2020-12-25)
InputMethod: ReidlineInputMethod with Reline 0.2.0
.irbrc path: /home/pocke/.irbrc

I used the current HEAD of irb and reline.
88b6542
ruby/reline@9ec0304

I can reproduce it on Ruby v2.7.2 and v3.0.0 also.

Terminal Emulator

Sakura Terminal Emulator on Arch Linux.

Setting Files

Are you using ~/.irbrc and ~/.inputrc?

I use ~/.irbrc but I can reproduce it even if the irbrc is empty.
~/.inputrc doesn't exist.

Related ticket

https://bugs.ruby-lang.org/issues/17503

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions