From bc2a9fe780e44fcf3fb989178b0582a8f2514895 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 31 Mar 2013 20:45:54 -0700 Subject: [PATCH] VBoxManage errors show stderr --- CHANGELOG.md | 2 ++ plugins/providers/virtualbox/driver/base.rb | 15 +++++++++++++-- templates/locales/en.yml | 8 ++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b8803675..e0fcc99b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ IMPROVEMENTS: - Vagrant will detect Bundler environments, make assumptions that you're developing plugins, and will quiet its error output a bit. - More comprehensive synced folder configuration validation. + - VBoxManage errors now show the output from the command so that + users can potentially know what is wrong. BUG FIXES: diff --git a/plugins/providers/virtualbox/driver/base.rb b/plugins/providers/virtualbox/driver/base.rb index a3892eb06..179a4bd38 100644 --- a/plugins/providers/virtualbox/driver/base.rb +++ b/plugins/providers/virtualbox/driver/base.rb @@ -279,6 +279,9 @@ module VagrantPlugins # Variable to store our execution result r = nil + # If there is an error with VBoxManage, this gets set to true + errored = false + retryable(:on => Vagrant::Errors::VBoxManageError, :tries => tries, :sleep => 1) do # Execute the command r = raw(*command, &block) @@ -294,7 +297,7 @@ module VagrantPlugins # This is usually indicative of a corrupted VirtualBox install. raise Vagrant::Errors::VBoxManageNotFoundError else - raise Vagrant::Errors::VBoxManageError, :command => command.inspect + errored = true end else # Sometimes, VBoxManage fails but doesn't actual return a non-zero @@ -302,11 +305,19 @@ module VagrantPlugins # occurred. if r.stderr =~ /VBoxManage: error:/ @logger.info("VBoxManage error text found, assuming error.") - raise Vagrant::Errors::VBoxManageError, :command => command.inspect + errored = true end end end + # If there was an error running VBoxManage, show the error and the + # output. + if errored + raise Vagrant::Errors::VBoxManageError, + :command => command.inspect, + :stderr => r.stderr + end + # Return the output, making sure to replace any Windows-style # newlines with Unix-style. r.stdout.gsub("\r\n", "\n") diff --git a/templates/locales/en.yml b/templates/locales/en.yml index aa370a7f7..5428e5a8d 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -386,12 +386,12 @@ en: %{file} vboxmanage_error: |- - There was an error executing the following command with VBoxManage: + There was an error while executing `VBoxManage`, a CLI used by Vagrant + for controlling VirtualBox. The command and stderr is shown below. - %{command} + Command: %{command} - For more information on the failure, enable detailed logging by setting - the environment variable VAGRANT_LOG to DEBUG. + Stderr: %{stderr} vboxmanage_not_found_error: |- The "VBoxManage" command or one of its dependencies could not be found. Please verify VirtualBox is properly installed. You can verify