TruffleRuby v20.1.0 doesn't patch StringIO
piotrmurach opened this issue · comments
Using MRI Ruby and JRuby loading "io/console"
extends StringIO
with extra methods.
For example:
require "stringio"
sio = StringIO.new
sio.respond_to?(:getch) # => false
then loading "io/console"
adds getch
support:
require "io/console"
sio.respond_to?(:getch) # => true
With TruffleRuby, that's not the case:
require "io/console"
sio.respond_to?(:getch) # => false
I'm using TruffleRuby v20.1.0
locally and the failure is also happening in the Travis CI
Hopefully, this helps to identify the issue and apologies if this is already fixed.
Thanks for the report.
Currently TruffleRuby and JRuby use a separate implementation for io/console than this gem (#10/#11, 41b6f09).
It looks like JRuby has that behavior with
https://github.com/jruby/jruby/blob/9.2.8.0/lib/ruby/stdlib/io/console/common.rb#L23-L34
I'll copy that logic over to TruffleRuby.
The C extension OTOH does this with a hidden (lowercase!) constant in
io-console/ext/io/console/console.c
Line 1646 in 2b8ba02
Which looks funny for:
$ ruby -rstringio -e 'p StringIO.ancestors'
[StringIO, IO::generic_writable, IO::generic_readable, Enumerable, Data, Object, Kernel, BasicObject]
TruffleRuby doesn't support yet such constants, and it's actually the first error with:
$ chruby truffleruby-dev
$ gem i io-console:0.5.5
$ ruby -rio/console.so -e0
/home/eregon/.rubies/truffleruby-dev/lib/truffle/truffle/cext.rb:1081:in `const_defined?': wrong constant name generic_readable (NameError)
from /home/eregon/.rubies/truffleruby-dev/lib/truffle/truffle/cext.rb:1081:in `rb_define_module_under'
from define.c:26:in `rb_define_module_under'
from /home/eregon/.rubies/truffleruby-dev/lib/gems/gems/io-console-0.5.5/ext/io/console/console.c:1637:in `InitVM_console'
Fixed in oracle/truffleruby@75b6f5f, thanks for the report.