Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Calling IO.console twice raises NoMethodError for `#open?` #3530
Code to reproduce:
IO.console # #<File:/dev/tty> IO.console NoMethodError: undefined method `open?' for #<File:/dev/tty> from /Users/davida/.rvm/rubies/jruby-188.8.131.52/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
Problem is in line:
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-184.108.40.206/bin/irb:13:in `<top>'