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

Calling IO.console twice raises NoMethodError for #open? #3530

Closed
hobodave opened this issue Dec 10, 2015 · 2 comments
Closed

Calling IO.console twice raises NoMethodError for #open? #3530

hobodave opened this issue Dec 10, 2015 · 2 comments
Labels
Milestone

Comments

@hobodave
Copy link

Code to reproduce:

IO.console # #<File:/dev/tty>
IO.console
NoMethodError: undefined method `open?' for #<File:/dev/tty>
    from /Users/davida/.rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib/io/console.rb:159:in `console'
    from (irb):2:in `<eval>'

In order to use the console returned by IO.console you have to store a reference to it:

# Explodes
IO.console.winsize # [60, 120]
IO.console.winsize 

# Works
c = IO.console
c.winsize # [60, 120]

# Also works
IO.console
IO.instance_variable_get(:@console).winsize
@kml
Copy link

kml commented Dec 10, 2015

Problem is in line:
https://github.com/jruby/jruby/blob/master/lib/ruby/stdlib/io/console.rb#L159

Fix did not helped: 94423c4

>> con = File.open('/dev/tty', 'r+') # or just File.new("test.txt", "w")
=> #<File:/dev/tty>
>> con.kind_of?(File)
=> true
>> con.kind_of?(IO)
=> true
>> con.open?
NoMethodError: undefined method `open?' for #<File:/dev/tty>
    from (irb):10: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 ~/.rvm/rubies/jruby-9.0.4.0/bin/irb:13:in `<top>'

@kares kares added the stdlib label Jan 15, 2016
@kares kares added this to the JRuby 9.0.5.0 milestone Jan 15, 2016
@kares kares closed this as completed in 343f2a9 Jan 15, 2016
@hobodave
Copy link
Author

hobodave commented Feb 2, 2016

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants