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> #62

Closed
adamdilek opened this issue Sep 20, 2015 · 7 comments
Closed

Comments

@adamdilek
Copy link

I'm getting this error in JRuby

cap aborted!
NoMethodError: undefined method `open?' for #<File:/dev/tty>
/usr/local/rbenv/versions/jruby-9.0.0.0/lib/ruby/stdlib/io/console.rb:159:in `console'
/usr/local/rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/airbrussh-0.5.1/lib/airbrussh/console.rb:59:in `console_width'
/usr/local/rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/airbrussh-0.5.1/lib/airbrussh/console.rb:42:in `truncate_to_console_width'
/usr/local/rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/airbrussh-0.5.1/lib/airbrussh/console.rb:26:in `print_line'
/usr/local/rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/airbrussh-0.5.1/lib/airbrussh/formatter.rb:174:in `print_line'
/usr/local/rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/airbrussh-0.5.1/lib/airbrussh/formatter.rb:42:in `write_banner'
/usr/local/rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/airbrussh-0.5.1/lib/airbrussh/formatter.rb:28:in `initialize'
/usr/local/rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sshkit-1.7.1/lib/sshkit/configuration.rb:48:in `block in formatter'
@mattbrictson
Copy link
Owner

Thanks for the report. For now, you can probably work around this by disabling auto-truncation. Try putting this code in your deploy.rb:

Airbrussh.configure do |config|
  config.truncate = false
end

@mattbrictson
Copy link
Owner

I've confirmed this is a bug in jruby: the IO.console.winsize method doesn't work.

>> require "io/console"
false
>> IO.console
#<File:/dev/tty>
crw-rw-rw-  1 root  wheel    2,   0 Sep 19 09:11 /dev/tty
>> IO.console.winsize
NoMethodError: undefined method `open?' for #<File:/dev/tty>
    from /Users/mbrictson/.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 /Users/mbrictson/.rbenv/versions/jruby-9.0.0.0/bin/irb:13:in `<top>'

@muhammett can you open a bug report in https://github.com/jruby/jruby ?

@adamdilek
Copy link
Author

Thank you @mattbrictson . I report to jruby jruby/jruby#3340

@mattbrictson
Copy link
Owner

This is apparently fixed in the next release of JRuby 9.x. I've also added a JRuby compatibility note to the Airbrussh README in ce927be. Closing.

@hron84
Copy link

hron84 commented Sep 20, 2016

@mattbrictson IO.console could be also nil if Ruby executable is called through a sudo su - user -c '~/.rvm/bin/rvm 2.3.1 do ruby -e -e "require %{io/console}; puts IO.console.winsize"' construction. It should be nil-checked anyway.

(To be honest, in this case @output.tty? should not be true, I think it's a bug in ruby, but should be workarounded.

$  sudo su - app -c 'cd /deploy/ && /home/app/.rvm/bin/rvm ruby-2.3.1@default do ruby -e "require %{io/console}; puts IO.console.winsize"'
-e:1:in `<main>': undefined method `winsize' for nil:NilClass (NoMethodError)

$ /home/app/.rvm/bin/rvm ruby-2.3.1@default do ruby -e "require %{io/console}; puts IO.console.winsize"
55
211
$ 

@mattbrictson
Copy link
Owner

IO.console could be also nil

@hron84 Thanks for pointing that out! Can you open a new Airbrussh issue for the nil problem? It is not related to JRuby so it should be logged as a separate issue.

@hron84
Copy link

hron84 commented Sep 22, 2016

@mattbrictson #96

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

3 participants