From 3e5b3d051b313026e1ea3dbb74f091cf078d66f3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 20 Feb 2012 17:26:22 -0800 Subject: [PATCH] Fix exception when adding boxes due to recent change. [GH-752] --- lib/vagrant/action/general/check_virtualbox.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/action/general/check_virtualbox.rb b/lib/vagrant/action/general/check_virtualbox.rb index fe4c55378..cbaecc8ec 100644 --- a/lib/vagrant/action/general/check_virtualbox.rb +++ b/lib/vagrant/action/general/check_virtualbox.rb @@ -8,7 +8,18 @@ module Vagrant end def call(env) - env[:vm].driver.verify! + # Certain actions may not actually have a VM, and thus no + # driver, so we have to be clever about obtaining an instance + # of the driver. + driver = nil + driver = env[:vm].driver if env[:vm] + driver = Driver::VirtualBox.new(nil) if !driver + + # Verify that it is ready to go! This will raise an exception + # if anything goes wrong. + driver.verify! + + # Carry on. @app.call(env) end end