Don't error if box doesn't exist on load
This commit is contained in:
parent
a4713d5a84
commit
819140bbc2
|
@ -181,13 +181,18 @@ module Vagrant
|
|||
retry
|
||||
end
|
||||
|
||||
box_vagrantfile = find_vagrantfile(box.directory)
|
||||
if box_vagrantfile
|
||||
# The box has a custom Vagrantfile, so we load that into the config
|
||||
# as well.
|
||||
box_config_key = "box_#{box.name}_#{box.provider}".to_sym
|
||||
@config_loader.set(box_config_key, box_vagrantfile)
|
||||
config = @config_loader.load([:default, box_config_key, :home, :root, vm_config_key])
|
||||
# If a box was found, then we attempt to load the Vagrantfile for
|
||||
# that box. We don't require a box since we allow providers to download
|
||||
# boxes and so on.
|
||||
if box
|
||||
box_vagrantfile = find_vagrantfile(box.directory)
|
||||
if box_vagrantfile
|
||||
# The box has a custom Vagrantfile, so we load that into the config
|
||||
# as well.
|
||||
box_config_key = "box_#{box.name}_#{box.provider}".to_sym
|
||||
@config_loader.set(box_config_key, box_vagrantfile)
|
||||
config = @config_loader.load([:default, box_config_key, :home, :root, vm_config_key])
|
||||
end
|
||||
end
|
||||
|
||||
# Create the machine and cache it for future calls. This will also
|
||||
|
|
|
@ -235,6 +235,22 @@ VF
|
|||
vm2_foo.should eql(env.machine(:vm2, :foo))
|
||||
end
|
||||
|
||||
it "should load a machine without a box" do
|
||||
register_provider("foo")
|
||||
|
||||
environment = isolated_environment do |env|
|
||||
env.vagrantfile(<<-VF)
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "i-dont-exist"
|
||||
end
|
||||
VF
|
||||
end
|
||||
|
||||
env = environment.create_vagrant_env
|
||||
machine = env.machine(:default, :foo)
|
||||
machine.box.should be_nil
|
||||
end
|
||||
|
||||
it "should load the machine configuration" do
|
||||
register_provider("foo")
|
||||
|
||||
|
|
Loading…
Reference in New Issue