diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 1377464bb..dc24536d3 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -163,6 +163,14 @@ module Vagrant error_key(:cli_invalid_options) end + class CommandUnavailable < VagrantError + error_key(:command_unavailable) + end + + class CommandUnavailableWindows < VagrantError + error_key(:command_unavailable_windows) + end + class ConfigInvalid < VagrantError error_key(:config_invalid) end diff --git a/lib/vagrant/util/subprocess.rb b/lib/vagrant/util/subprocess.rb index 8003cdc0f..c0e776449 100644 --- a/lib/vagrant/util/subprocess.rb +++ b/lib/vagrant/util/subprocess.rb @@ -5,6 +5,7 @@ require 'log4r' require 'vagrant/util/platform' require 'vagrant/util/safe_chdir' +require 'vagrant/util/which' module Vagrant module Util @@ -26,10 +27,10 @@ module Vagrant def initialize(*command) @options = command.last.is_a?(Hash) ? command.pop : {} @command = command - if Platform.windows? - locations = `where #{command[0]}` - new_command = "#{locations.split("\n")[0]}" - @command[0] = new_command if $?.success? and File.exists?(new_command) + @command[0] = Which.which(@command[0]) + unless @command[0] + raise Errors::CommandUnavailableWindows if Platform.windows? + raise Errors::CommandUnavailable end @logger = Log4r::Logger.new("vagrant::util::subprocess") end