@kyanny's blog

My thoughts, my life. Views/opinions are my own.

Ruby 3.1.2 に付属の irb 1.3.7 で pipe すると `winsize': Inappropriate ioctl for device (Errno::ENOTTY) エラーが出るときの対処法

こういう現象。

❯ ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]

❯ irb -v
irb 1.4.1 (2021-12-25)

❯ echo n=1 | irb | cat
Switch to inspect mode.
n=1
/Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb/input-method.rb:43:in `winsize': Inappropriate ioctl for device (Errno::ENOTTY)
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb/input-method.rb:43:in `winsize'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb.rb:819:in `output_value'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb.rb:582:in `block (2 levels) in eval_input'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb.rb:770:in `signal_status'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb.rb:558:in `block in eval_input'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb/ruby-lex.rb:268:in `block (2 levels) in each_top_level_statement'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb/ruby-lex.rb:250:in `loop'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb/ruby-lex.rb:250:in `block in each_top_level_statement'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb/ruby-lex.rb:249:in `catch'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb/ruby-lex.rb:249:in `each_top_level_statement'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb.rb:557:in `eval_input'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb.rb:491:in `block in run'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb.rb:490:in `catch'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb.rb:490:in `run'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/3.1.0/irb.rb:419:in `start'
    from /Users/kyanny/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
    from /Users/kyanny/.rbenv/versions/3.1.2/bin/irb:25:in `load'
    from /Users/kyanny/.rbenv/versions/3.1.2/bin/irb:25:in `<main>'
Maybe IRB bug!

こういうパッチがある。

github.com

Ruby 3.2.0 とかで治るのだと思うが、それまでは↓のようなワークアラウンドで回避できる。

gist.github.com