Skip to content

Commit

Permalink
Merge pull request hashicorp#1783 from Aigeruth/issue-654
Browse files Browse the repository at this point in the history
Check for binaries as part of Subprocess
  • Loading branch information
mitchellh committed Jun 9, 2013
2 parents cf2f6da + a4979c4 commit 8906ae0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/vagrant/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ class CLIInvalidOptions < VagrantError
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
Expand Down
6 changes: 6 additions & 0 deletions lib/vagrant/util/subprocess.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

require 'vagrant/util/platform'
require 'vagrant/util/safe_chdir'
require 'vagrant/util/which'

module Vagrant
module Util
Expand All @@ -26,6 +27,11 @@ def self.execute(*command, &block)
def initialize(*command)
@options = command.last.is_a?(Hash) ? command.pop : {}
@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")
end

Expand Down
2 changes: 2 additions & 0 deletions templates/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8906ae0

Please sign in to comment.