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
muhammet opened this Issue Sep 21, 2015 · 4 comments

Comments

Projects
None yet
5 participants
@muhammet

muhammet commented Sep 21, 2015

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

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Sep 22, 2015

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@mattbrictson

mattbrictson Feb 2, 2016

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>'

mattbrictson commented Feb 2, 2016

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

This comment has been minimized.

Show comment
Hide comment
@headius

headius Mar 4, 2016

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@headius

headius Mar 4, 2016

Member

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.

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