Don't require root path to load an environment. (Makes `vagrant box` commands work again without a Vagrantfile)
This commit is contained in:
parent
49df1875c4
commit
ba8307712d
|
@ -12,6 +12,8 @@ module Vagrant
|
||||||
# This returns an array of {VM} objects depending on the arguments
|
# This returns an array of {VM} objects depending on the arguments
|
||||||
# given to the command.
|
# given to the command.
|
||||||
def target_vms(name=nil)
|
def target_vms(name=nil)
|
||||||
|
raise Errors::NoEnvironmentError.new if !env.root_path
|
||||||
|
|
||||||
name ||= self.name rescue nil
|
name ||= self.name rescue nil
|
||||||
|
|
||||||
@target_vms ||= begin
|
@target_vms ||= begin
|
||||||
|
|
|
@ -220,7 +220,6 @@ module Vagrant
|
||||||
def load!
|
def load!
|
||||||
if !loaded?
|
if !loaded?
|
||||||
@loaded = true
|
@loaded = true
|
||||||
raise Errors::NoEnvironmentError.new if !root_path
|
|
||||||
self.class.check_virtualbox!
|
self.class.check_virtualbox!
|
||||||
load_config!
|
load_config!
|
||||||
load_vm!
|
load_vm!
|
||||||
|
@ -242,7 +241,7 @@ module Vagrant
|
||||||
loader.queue << File.expand_path("config/default.rb", Vagrant.source_root)
|
loader.queue << File.expand_path("config/default.rb", Vagrant.source_root)
|
||||||
loader.queue << File.join(box.directory, ROOTFILE_NAME) if !first_run && box
|
loader.queue << File.join(box.directory, ROOTFILE_NAME) if !first_run && box
|
||||||
loader.queue << File.join(home_path, ROOTFILE_NAME) if !first_run && home_path
|
loader.queue << File.join(home_path, ROOTFILE_NAME) if !first_run && home_path
|
||||||
loader.queue << File.join(root_path, ROOTFILE_NAME)
|
loader.queue << File.join(root_path, ROOTFILE_NAME) if root_path
|
||||||
|
|
||||||
# If this environment is representing a sub-VM, then we push that
|
# If this environment is representing a sub-VM, then we push that
|
||||||
# proc on as the last configuration.
|
# proc on as the last configuration.
|
||||||
|
|
|
@ -27,7 +27,14 @@ class CommandHelpersTest < Test::Unit::TestCase
|
||||||
context "vms from args" do
|
context "vms from args" do
|
||||||
setup do
|
setup do
|
||||||
@env = vagrant_env
|
@env = vagrant_env
|
||||||
@env.stubs(:root_path).returns(7)
|
end
|
||||||
|
|
||||||
|
should "raise an exception if no root path" do
|
||||||
|
@env.stubs(:root_path).returns(nil)
|
||||||
|
|
||||||
|
assert_raises(Vagrant::Errors::NoEnvironmentError) {
|
||||||
|
command([], @env).target_vms
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
should "only calculate the result once" do
|
should "only calculate the result once" do
|
||||||
|
|
Loading…
Reference in New Issue