From 093626731455ab24f31127205e2a504e8a0acb81 Mon Sep 17 00:00:00 2001 From: Gabor Nagy Date: Sat, 1 Jun 2013 14:29:45 +0200 Subject: [PATCH 1/3] Fixes [GH-654] on Windows 8x64 and Ruby 1.9.3p374 Replaces the command with absolute path version if it exists. --- lib/vagrant/util/subprocess.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/vagrant/util/subprocess.rb b/lib/vagrant/util/subprocess.rb index 4379304b8..8003cdc0f 100644 --- a/lib/vagrant/util/subprocess.rb +++ b/lib/vagrant/util/subprocess.rb @@ -26,6 +26,11 @@ 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) + end @logger = Log4r::Logger.new("vagrant::util::subprocess") end From 4c00abe69eba77c36823c6ea09aa07d8aedf9445 Mon Sep 17 00:00:00 2001 From: Gabor Nagy Date: Sun, 2 Jun 2013 03:48:47 +0200 Subject: [PATCH 2/3] Modifies to use util/which [GH-654] --- lib/vagrant/errors.rb | 8 ++++++++ lib/vagrant/util/subprocess.rb | 9 +++++---- 2 files changed, 13 insertions(+), 4 deletions(-) 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 From a4979c4824354e956370b848ecc6715f25d14cb5 Mon Sep 17 00:00:00 2001 From: Gabor Nagy Date: Mon, 3 Jun 2013 00:04:25 +0200 Subject: [PATCH 3/3] [GH-654] Missing condition and translations --- lib/vagrant/util/subprocess.rb | 2 +- templates/locales/en.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/util/subprocess.rb b/lib/vagrant/util/subprocess.rb index c0e776449..c9be8eafe 100644 --- a/lib/vagrant/util/subprocess.rb +++ b/lib/vagrant/util/subprocess.rb @@ -27,7 +27,7 @@ module Vagrant def initialize(*command) @options = command.last.is_a?(Hash) ? command.pop : {} @command = command - @command[0] = Which.which(@command[0]) + @command[0] = Which.which(@command[0]) unless File.exists? @command[0] unless @command[0] raise Errors::CommandUnavailableWindows if Platform.windows? raise Errors::CommandUnavailable diff --git a/templates/locales/en.yml b/templates/locales/en.yml index b5d423b0b..c4963e8b9 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -167,6 +167,8 @@ en: available below. %{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: |- There are errors in the configuration of this machine. Please fix the following errors and try again: