Repository navigation
Closed
Labels
bugSomething isn't working
Description
Description
In Mac, Reline crashes if stdout is a tty and stdin is not a tty. This behavior depends on environment. It works in CI. test_with_newline in test_rendering.rb passes.
% (printf 'hello') | ruby -rreline -e "p Reline.readline '> '"
# In macOS, Terminal.app, zsh
▽/Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/reline-0.3.3/lib/reline/ansi.rb:273:in `pread': not opened for reading (IOError)
from /Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/reline-0.3.3/lib/reline/ansi.rb:273:in `rescue in cursor_pos'
from /Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/reline-0.3.3/lib/reline/ansi.rb:252:in `cursor_pos'
from /Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/reline-0.3.3/lib/reline.rb:498:in `may_req_ambiguous_char_width'
from /Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/reline-0.3.3/lib/reline.rb:311:in `inner_readline'
from /Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/reline-0.3.3/lib/reline.rb:287:in `readline'
from /Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/3.2.0/forwardable.rb:240:in `readline'
from -e:1:in `<main>'
/Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/reline-0.3.3/lib/reline/ansi.rb:255:in `raw': Inappropriate ioctl for device (Errno::ENOTTY)
from /Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/reline-0.3.3/lib/reline/ansi.rb:255:in `cursor_pos'
from /Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/reline-0.3.3/lib/reline.rb:498:in `may_req_ambiguous_char_width'
from /Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/reline-0.3.3/lib/reline.rb:311:in `inner_readline'
from /Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/reline-0.3.3/lib/reline.rb:287:in `readline'
from /Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/3.2.0/forwardable.rb:240:in `readline'
from -e:1:in `<main>'
# Inside docker (docker run --rm -ti rubylang/rubyfarm sh)
> hello
"hello"
In the above example, it seems working in docker, but actually it's not.
# (printf 'he';sleep 1;printf 'llo') | ruby -rreadline -e "p Readline.readline '> '"
> hello
"hello"
# (printf 'he';sleep 1;printf 'llo') | ruby -rreline -e "p Reline.readline '> '"
> he
"he"
# ruby -v
ruby 3.3.0dev (2023-05-01T12:20:20Z master 13dfbcf7bf) [x86_64-linux]
# ruby -rreline -e "puts Reline::VERSION"
0.3.3
Terminal Emulator
macOS Terminal.app
Reacted by Aaron Breckenridge
Reacted by Jay Schneider
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
revolter commentedon Apr 1, 2024
Could this be the same error as:
?
It's only triggered when we:
git commitTTY::Screen.widthcc @bpoplauschi
forthrin commentedon Apr 7, 2024
vtamara commentedon Apr 26, 2024
On OpenBSD/adJ 7.4 I don't see the problem that @forthrin reports by running:
But I see the same error
reline-0.5.3/lib/reline/ansi.rb:246:in 'winsize': Operation not supported by device - <STDIN> (Errno::ENODEV)described by him and by @revolter in a different scenario that I described in the issue #690.tompng commentedon Apr 26, 2024
#659 also adds
rescue Errno::ENODEVkaoru commentedon Apr 30, 2024
I think we might be seeing the originally described bug "Reline.readline does not work if STDOUT is a tty and STDIN is not a tty" when working on a Rails app with hookup. Hookup automatically runs
rake db:migrateandbundle installwhen switching branches, but it runsdb:migratewith a closed STDIN and that causes thisLoadError: cannot load such file -- readline.bundle (LoadError)to appear.I have been able to reproduce this with a new rails app like so:
And removing the following line from the Gemfile fixes it:
Which I think points to reline, as it is a dependency of the debug gem.
Adding the following line to the Gemfile:
Seems to fix it, which points to #659 as being a good fix.
However, I've only tested that with empty/no-op
db:migratecalls so I can't say for sure that it's working fully.kaoru commentedon May 29, 2024
This seems to be fixed in https://github.com/ruby/reline/releases/tag/v0.5.7 -
bin/rails db:migrate < /dev/nullis no longer throwingErrno::ENODEV: Operation not supported by devicesince we upgraded.tompng commentedon May 29, 2024
Original issue
pread: not opened for readingis fixed in #671The
bin/rails db:migrate < /dev/nullproblem mentioned here is fixed in #703