From c3b26dc4bf1e8ac8bf4db99fce1127a781866c61 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 18 Dec 2010 20:50:32 -0800 Subject: [PATCH] Show special error if VirtualBox not detected on 64-bit Win --- CHANGELOG.md | 1 + lib/vagrant/environment.rb | 8 ++++++++ lib/vagrant/errors.rb | 9 +++++++++ templates/locales/en.yml | 13 ++++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42574ff8a..6c19ace27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - BSD hosts use proper GNU sed syntax for clearing NFS shares. [GH-243] - Enumerate VMs in a multi-VM environment in order they were defined. [GH-244] - Check for VM boot changed to use `timeout` library, which works better with Windows. + - Show special error if VirtualBox not detected on 64-bit Windows. ## 0.6.8 (November 30, 2010) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index f3fe5c6e5..e2b450874 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -34,6 +34,14 @@ module Vagrant raise Errors::VirtualBoxNotDetected.new if version.nil? raise Errors::VirtualBoxInvalidVersion.new(:version => version.to_s) if version.to_f < 3.2 raise Errors::VirtualBoxInvalidOSE.new(:version => version.to_s) if version.to_s.downcase.include?("ose") + rescue Errors::VirtualBoxNotDetected + # On 64-bit Windows, show a special error. This error is a subclass + # of VirtualBoxNotDetected, so libraries which use Vagrant can just + # rescue VirtualBoxNotDetected. + raise Errors::VirtualBoxNotDetected_Win64 if Util::Platform.windows? && Util::Platform.bit64? + + # Otherwise, reraise the old error + raise end end diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 3eac27f54..cf1447ef0 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -283,6 +283,15 @@ module Vagrant error_key(:virtualbox_not_detected) end + # Note that this is a subclass of VirtualBoxNotDetected, so developers + # who script Vagrant or use it as a library in any way can rescue from + # "VirtualBoxNotDetected" and catch both errors, which represent the + # same thing. This subclass simply has a specialized error message. + class VirtualBoxNotDetected_Win64 < VirtualBoxNotDetected + status_code(48) + error_key(:virtualbox_not_detected_win64) + end + class VMBaseMacNotSpecified < VagrantError status_code(47) error_key(:no_base_mac, "vagrant.actions.vm.match_mac") diff --git a/templates/locales/en.yml b/templates/locales/en.yml index ff3286e77..2081b2505 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -14,7 +14,7 @@ en: the VM and is required for chef provisioning. Please verify that chef is installed and that the binary is available on the PATH. puppet_not_detected: |- - The `puppet` binary was not found on the VM and is required for Puppet provisioning. + The `puppet` binary was not found on the VM and is required for Puppet provisioning. Please verify that Puppet is installed and that the binary is available on the PATH. cli_missing_env: This command requires that a Vagrant environment be properly passed in as the last parameter. config_validation: |- @@ -102,6 +102,17 @@ en: Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed. If VirtualBox is installed, it may be an incorrect version. Vagrant currently requires VirtualBox 3.2.x. Please install the proper version to continue. + virtualbox_not_detected_win64: |- + Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed + with version 3.2.0 or higher. + + Additionally, it appears you're on 64-bit Windows. If this is the case, and + VirtualBox is properly installed with the correct version, then please make + sure you're running Vagrant via JRuby on a 64-bit Java runtime. For more + information on how to set this up and how to verify it is properly setup, + please view the guide online at: + + URL TODO vm_creation_required: "VM must be created before running this command. Run `vagrant up` first." vm_not_found: "A VM by the name of %{name} was not found." vm_not_running: "VM must be running to open SSH connection."