From f0294039e120442bdcaa2de6e7a3ffd2bf3643b8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 21 Sep 2010 01:47:50 -0600 Subject: [PATCH] Load config files (only) early so plugins are loaded from Vagrantfiles --- bin/vagrant | 7 +++++++ lib/vagrant/command/helpers.rb | 1 - test/vagrant/command/helpers_test.rb | 6 ------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/vagrant b/bin/vagrant index e07c42423..31bb4ca93 100755 --- a/bin/vagrant +++ b/bin/vagrant @@ -5,6 +5,13 @@ require 'vagrant/cli' env = Vagrant::Environment.new begin + # Set the UI early in case any errors are raised, and load + # the config immediately, so we gather any new commands from + # plugins + env.ui = Vagrant::UI::Shell.new(env, Thor::Base.shell.new) + env.load! + + # Kick start the CLI Vagrant::CLI.start(ARGV, :env => env) rescue Vagrant::Errors::VagrantError => e opts = { :_translate => false, :_prefix => false } diff --git a/lib/vagrant/command/helpers.rb b/lib/vagrant/command/helpers.rb index 7b074b85b..d5af59d4a 100644 --- a/lib/vagrant/command/helpers.rb +++ b/lib/vagrant/command/helpers.rb @@ -6,7 +6,6 @@ module Vagrant def initialize_environment(args, options, config) raise Errors::CLIMissingEnvironment.new if !config[:env] @env = config[:env] - @env.ui = UI::Shell.new(@env, shell) if !@env.ui.is_a?(UI::Shell) end # This returns an array of {VM} objects depending on the arguments diff --git a/test/vagrant/command/helpers_test.rb b/test/vagrant/command/helpers_test.rb index c47548992..19057fb3e 100644 --- a/test/vagrant/command/helpers_test.rb +++ b/test/vagrant/command/helpers_test.rb @@ -16,12 +16,6 @@ class CommandHelpersTest < Test::Unit::TestCase should "raise an exception if no environment is given" do assert_raises(Vagrant::Errors::CLIMissingEnvironment) { command([], nil) } end - - should "not raise an exception if environment is given and setup UI" do - env = vagrant_env - assert_nothing_raised { command([], env) } - assert env.ui.is_a?(Vagrant::UI::Shell) - end end context "vms from args" do