Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JRuby NoMethodError: undefined method `open?' for #<File:/dev/tty> #3340

Closed
adamdilek opened this issue Sep 21, 2015 · 4 comments
Closed

JRuby NoMethodError: undefined method `open?' for #<File:/dev/tty> #3340

adamdilek opened this issue Sep 21, 2015 · 4 comments

Comments

@adamdilek
Copy link

Im getting this error when using airbrush. I report to them mattbrictson/airbrussh#62 and he checked this is jruby's bug.

irb(main):001:0> require "io/console"
=> false
irb(main):002:0> IO.console
=> #<File:/dev/tty>
irb(main):003:0> IO.console.winsize
NoMethodError: undefined method `open?' for #<File:/dev/tty>
    from /usr/local/rbenv/versions/jruby-9.0.0.0/lib/ruby/stdlib/io/console.rb:159:in `console'
    from (irb):3:in `<eval>'
    from org/jruby/RubyKernel.java:979:in `eval'
    from org/jruby/RubyKernel.java:1292:in `loop'
    from org/jruby/RubyKernel.java:1099:in `catch'
    from org/jruby/RubyKernel.java:1099:in `catch'
    from /usr/local/rbenv/versions/jruby-9.0.0.0/bin/irb:13:in `<top>'
irb(main):004:0>
@enebo
Copy link
Member

enebo commented Sep 22, 2015

So I get the same behavior with my fix as MRI does but I had to make a guess. My guess was that since we are assuming that branch was dealing with an IO we should make sure it is in fact an IO before calling open?.

MRI implements all this in C and we implement ours in Ruby so a side-by-side comparison is difficult. I definitely made sure we will only safely call open? and the comment next to this like implies something about digging in internals of IO.

@mattbrictson
Copy link

This is still a problem on JRuby 9.0.4.0:

$ ruby -v
jruby 9.0.4.0 (2.2.2) 2015-11-12 b9fb7aa Java HotSpot(TM) 64-Bit Server VM 24.71-b01 on 1.7.0_71-b14 +jit [darwin-x86_64]
$ irb
>> require "io/console"
false
>> IO.console
#<File:/dev/tty>
crw-rw-rw-  1 root  wheel    2,   0 Feb  2 07:28 /dev/tty
>> IO.console.winsize
NoMethodError: undefined method `open?' for #<File:/dev/tty>
    from /Users/mbrictson/.rbenv/versions/jruby-9.0.4.0/lib/ruby/stdlib/io/console.rb:159:in `console'
    from (irb):3:in `<eval>'
    from org/jruby/RubyKernel.java:978:in `eval'
    from org/jruby/RubyKernel.java:1291:in `loop'
    from org/jruby/RubyKernel.java:1098:in `catch'
    from org/jruby/RubyKernel.java:1098:in `catch'
    from /Users/mbrictson/.rbenv/versions/jruby-9.0.4.0/bin/irb:13:in `<top>'

@headius
Copy link
Member

headius commented Mar 4, 2016

I am unable to reproduce on JRuby 9.1, but perhaps my io/console is loading and yours is not? You do appear to get the proper File opened on /dev/tty, but for some reason it doesn't have the methods it should.

@headius
Copy link
Member

headius commented Mar 4, 2016

Ah-ha, I believe this is fixed by @kares in 343f2a9, where he realizes there's no File#open? and replaces it with a proper call to File#closed?.

This is fixed as of JRuby 9.0.5.0.

@headius headius modified the milestones: JRuby 9.0.5.0, JRuby 9.0.2.0 Mar 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants