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

Fix IO.console_size to work when IO.console is not available #42

Closed
wants to merge 1 commit into from

Conversation

PChambino
Copy link
Contributor

At the moment, this works correctly when console method exists, but when it doesn't exist it actually fails with NameError instead of NoMethodError.

For example, when using JRuby on Linux aarch64 (related #40): (trimmed IRB output)

io/console on JRuby shells out to stty for most operations
irb(main):001:0> IO.console
(irb):1:in `evaluate': undefined method `console' for IO:Class (NoMethodError)
irb(main):003:0> require 'io/console/size'
irb(main):004:0> IO.console_size
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/io/console/size.rb:19:in `console_size': undefined local variable or method `console' for IO:Class (NameError)

With the change in this PR it works as expected.

At the moment, this works correctly when `console` method exists, but
when it doesn't exist it actually fails with NameError instead of NoMethodError.

For example, when using JRuby on Linux aarch64 (related ruby#40):
(trimmed IRB output)
```
io/console on JRuby shells out to stty for most operations
irb(main):001:0> IO.console
(irb):1:in `evaluate': undefined method `console' for IO:Class (NoMethodError)
irb(main):003:0> require 'io/console/size'
irb(main):004:0> IO.console_size
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/io/console/size.rb:19:in `console_size': undefined local variable or method `console' for IO:Class (NameError)
```

With the change in this PR it works as expected.
@nobu
Copy link
Member

nobu commented Aug 18, 2023

The receiver in IO.console_size should be IO (or a subclass of IO), and the explicit receiver IO should make no sense.
Probably sounds like an issue of JRuby implementation.

@nobu nobu closed this Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants