diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index b2a610723..db0bd036f 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -178,6 +178,10 @@ module Vagrant plugins = Vagrant::Plugin::Manager.instance.globalize! Vagrant::Plugin::Manager.instance.load_plugins(plugins) + # Reset so Vagrantfile will be reloaded with expected support for + # any new plugins provided + post_plugins_reset! + # Call the hooks that does not require configurations to be loaded # by using a "clean" action runner hook(:environment_plugins_loaded, runner: Action::Runner.new(env: self)) @@ -913,6 +917,18 @@ module Vagrant protected + # Unsets the internal vagrantfile and config_loader + # to force them to be regenerated. This is used after + # plugins have been loaded so that newly discovered + # plugin configurations are properly available + # + # @return [nil] + def post_plugins_reset! + @vagrantfile = nil + @config_loader = nil + nil + end + # Check for any local plugins defined within the Vagrantfile. If # found, validate they are available. If they are not available, # request to install them, or raise an exception diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 7f5745544..435db6ab3 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -25,6 +25,13 @@ describe Vagrant::Environment do let(:instance) { env.create_vagrant_env } subject { instance } + describe "#initialize" do + it "should do an internal reset after plugin loading" do + expect_any_instance_of(described_class).to receive(:post_plugins_reset!) + instance + end + end + describe "#can_install_provider?" do let(:plugin_hosts) { {} } let(:plugin_host_caps) { {} }