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

IO.console can be nil #96

Open
hron84 opened this issue Sep 22, 2016 · 0 comments
Open

IO.console can be nil #96

hron84 opened this issue Sep 22, 2016 · 0 comments

Comments

@hron84
Copy link

hron84 commented Sep 22, 2016

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.

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

2 participants