mattbrictson/airbrussh

IO.console can be nil

hron84 opened this issue · 0 comments

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? either should not be true (indicating the output is not a tty) or IO.console should be a valid TTY console, so this is a bug in MRI Ruby anyway, but should be workarounded as Ruby development and upgrading shipped versions in Linux distributions is much slower than any Gem development)

Example outputs:

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

My hack was adding and IO.console to the end of this line, but I am not sure it should be a right fix. It just provided me a working Capistrano run and I wasn't interested more in the solution.