Give a useful error if the VirtualBox.xml is not found [close GH-30]

This commit is contained in:
Mitchell Hashimoto 2010-03-17 01:25:02 -07:00
parent 73d0486c94
commit 723c36cb1d
2 changed files with 32 additions and 1 deletions

View File

@ -51,6 +51,23 @@ msg
Vagrant has detected that you have VirtualBox version #{version} installed!
Vagrant requires that you use at least VirtualBox version 3.1. Please install
a more recent version of VirtualBox to continue.
msg
end
if !VirtualBox::Global.vboxconfig?
error_and_exit(<<-msg)
Vagrant couldn't find your global VirtualBox.xml file!
If you just recently installed VirtualBox, make sure you've launched
it at least once, since the initial launch will typically create this
file.
Otherwise, you may need to set the path to the VirtualBox.xml file
manually. Note that 90% of people should never have to do this, so
don't be afraid to use the various Vagrant support lines to ask for
help. To set the path manually:
VirtualBox::Global.vboxconfig = "/path/to/VirtualBox.xml"
msg
end
end

View File

@ -17,7 +17,15 @@ class EnvTest < Test::Unit::TestCase
context "checking virtualbox version" do
setup do
VirtualBox::Command.stubs(:version)
VirtualBox::Command.stubs(:version).returns("3.1.4")
VirtualBox::Global.stubs(:vboxconfig?).returns(true)
end
should "not error and exit if everything is good" do
VirtualBox::Command.expects(:version).returns("3.1.4")
VirtualBox::Global.expects(:vboxconfig?).returns(true)
Vagrant::Env.expects(:error_and_exit).never
Vagrant::Env.check_virtualbox!
end
should "error and exit if VirtualBox is not installed or detected" do
@ -31,6 +39,12 @@ class EnvTest < Test::Unit::TestCase
VirtualBox::Command.expects(:version).returns("3.0.12r1041")
Vagrant::Env.check_virtualbox!
end
should "error and exit if the the vboxconfig is not set" do
VirtualBox::Global.expects(:vboxconfig?).returns(false)
Vagrant::Env.expects(:error_and_exit).once
Vagrant::Env.check_virtualbox!
end
end
context "requiring a VM" do