From ea139883674a022adc75a9550363e6a6e0a707e0 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 11 Nov 2016 14:24:25 -0800 Subject: [PATCH] Properly support plugin auto-loading with logging information --- lib/vagrant.rb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/vagrant.rb b/lib/vagrant.rb index 4fabcac96..b5328a08f 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -308,7 +308,29 @@ end if Vagrant.plugins_enabled? begin global_logger.info("Loading plugins!") - $vagrant_bundler_runtime.require(:plugins) + plugins.each do |plugin_name, plugin_info| + if plugin_info["require"].to_s.empty? + begin + global_logger.debug("Loading plugin `#{plugin_name}` with default require: `#{plugin_name}`") + require plugin_name + rescue LoadError, Gem::LoadError => load_error + if plugin_name.include?("-") + begin + plugin_slash = plugin_name.gsub("-", "/") + global_logger.debug("Failed to load plugin `#{plugin_name}` with default require.") + global_logger.debug("Loading plugin `#{plugin_name}` with slash require: `#{plugin_slash}`") + require plugin_slash + rescue LoadError, Gem::LoadError + raise load_error + end + end + end + else + global_logger.debug("Loading plugin `#{plugin_name}` with custom require: `#{plugin_info["require"]}`") + require plugin_info["require"] + end + global_logger.debug("Successfully loaded plugin `#{plugin_name}`.") + end rescue Exception => e raise Vagrant::Errors::PluginLoadError, message: e.to_s end