I am trying to check if system command exists with following code:
require 'open3'
Open3.popen3('non-existing command') do |stdin, stdout, stderr, thread|
exit_error = stderr.readlines
if exit_error["No such file or directory"]
puts "command not found"
end
end
However it simply crashes with following error message and doesn't proceed:
/home/pavel/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/open3.rb:211:in `spawn': No such file or directory - non-existing (Errno::ENOENT)
Why and how to fix it?