From 36fa04fd1e7fad5aaa7e6e6b89be1798caadaf98 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 5 Jul 2015 17:01:06 -0700 Subject: [PATCH] providers/virtualbox: catch subprocess launch error [GH-1483] --- CHANGELOG.md | 2 ++ lib/vagrant/errors.rb | 4 ++++ plugins/providers/virtualbox/driver/base.rb | 3 +++ templates/locales/en.yml | 9 ++++++++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d64c401c5..d67fa93e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,8 @@ BUG FIXES: - providers/hyperv: only set EFI secure boot for gen 2 machines [GH-5538] - providers/virtualbox: read netmask from dhcpservers [GH-5233] - providers/virtualbox: Fix exception when VirtualBox version is empty. [GH-5308] + - providers/virtualbox: Fix exception when VBoxManage.exe can't be run + on Windows [GH-1483] - provisioners/ansible: fix SSH settings to support more than 5 ssh keys [GH-5017] - provisioners/ansible: increase ansible connection timeout to 30 seconds [GH-5018] - provisioners/ansible: disable color if Vagrant is not colored [GH-5531, GH-5532] diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 3072d50ff..02804b5b0 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -720,6 +720,10 @@ module Vagrant error_key(:vboxmanage_error) end + class VBoxManageLaunchError < VagrantError + error_key(:vboxmanage_launch_error) + end + class VBoxManageNotFoundError < VagrantError error_key(:vboxmanage_not_found_error) end diff --git a/plugins/providers/virtualbox/driver/base.rb b/plugins/providers/virtualbox/driver/base.rb index da019eae8..112e97d5b 100644 --- a/plugins/providers/virtualbox/driver/base.rb +++ b/plugins/providers/virtualbox/driver/base.rb @@ -403,6 +403,9 @@ module VagrantPlugins Vagrant::Util::Busy.busy(int_callback) do Vagrant::Util::Subprocess.execute(@vboxmanage_path, *command, &block) end + rescue Vagrant::Util::Subprocess::LaunchError => e + raise Vagrant::Errors::VBoxManageLaunchError, + message: e.to_s end end end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index de90c426a..547ef7d0f 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1231,6 +1231,13 @@ en: Command: %{command} Stderr: %{stderr} + vboxmanage_launch_error: |- + There was an error running VBoxManage. This is usually a permissions + problem or installation problem with VirtualBox itself, and not Vagrant. + Please note the error message below (if any), resolve the issue, and + try Vagrant again. + + %{message} 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 @@ -1863,7 +1870,7 @@ en: %{manifest} environment_missing: |- - The configured Puppet environment folder %{environment} was not found in the + The configured Puppet environment folder %{environment} was not found in the specified environmentpath %{environmentpath}. Please specify a path to an existing Puppet directory environment. environment_path_missing: "The environment path specified for Puppet does not exist: %{path}"