Merge pull request #1783 from Aigeruth/issue-654

Check for binaries as part of Subprocess
This commit is contained in:
Mitchell Hashimoto 2013-06-09 13:48:21 -07:00
commit 8906ae01a8
3 changed files with 16 additions and 0 deletions

View File

@ -163,6 +163,14 @@ module Vagrant
error_key(:cli_invalid_options) error_key(:cli_invalid_options)
end end
class CommandUnavailable < VagrantError
error_key(:command_unavailable)
end
class CommandUnavailableWindows < VagrantError
error_key(:command_unavailable_windows)
end
class ConfigInvalid < VagrantError class ConfigInvalid < VagrantError
error_key(:config_invalid) error_key(:config_invalid)
end end

View File

@ -5,6 +5,7 @@ require 'log4r'
require 'vagrant/util/platform' require 'vagrant/util/platform'
require 'vagrant/util/safe_chdir' require 'vagrant/util/safe_chdir'
require 'vagrant/util/which'
module Vagrant module Vagrant
module Util module Util
@ -26,6 +27,11 @@ module Vagrant
def initialize(*command) def initialize(*command)
@options = command.last.is_a?(Hash) ? command.pop : {} @options = command.last.is_a?(Hash) ? command.pop : {}
@command = command @command = command
@command[0] = Which.which(@command[0]) unless File.exists? @command[0]
unless @command[0]
raise Errors::CommandUnavailableWindows if Platform.windows?
raise Errors::CommandUnavailable
end
@logger = Log4r::Logger.new("vagrant::util::subprocess") @logger = Log4r::Logger.new("vagrant::util::subprocess")
end end

View File

@ -167,6 +167,8 @@ en:
available below. available below.
%{help} %{help}
command_unavailable: "command binary could not be found. Is this application installed?"
command_unavailable_windows: "command executable not found in any directories in the %PATH% variable."
config_invalid: |- config_invalid: |-
There are errors in the configuration of this machine. Please fix There are errors in the configuration of this machine. Please fix
the following errors and try again: the following errors and try again: