Merge pull request #9808 from chrisroberts/f-vagrant-plugin-loading
Vagrant plugin updates
This commit is contained in:
commit
0b963a5213
11
bin/vagrant
11
bin/vagrant
|
@ -37,13 +37,18 @@ argv.each_index do |i|
|
||||||
arg = argv[i]
|
arg = argv[i]
|
||||||
|
|
||||||
if !arg.start_with?("-")
|
if !arg.start_with?("-")
|
||||||
if ["plugin", "help"].include?(arg) || (arg == "box" && argv[i+1] == "list")
|
if arg == "box" && argv[i+1] == "list"
|
||||||
opts[:vagrantfile_name] = ""
|
opts[:vagrantfile_name] = ""
|
||||||
ENV['VAGRANT_NO_PLUGINS'] = "1"
|
ENV['VAGRANT_NO_PLUGINS'] = "1"
|
||||||
end
|
end
|
||||||
|
|
||||||
if arg == "plugin" && argv[i+1] != "list"
|
# Do not load plugins when performing plugin operations
|
||||||
ENV['VAGRANT_DISABLE_PLUGIN_INIT'] = "1"
|
if arg == "plugin"
|
||||||
|
ENV['VAGRANT_NO_PLUGINS'] = "1"
|
||||||
|
# Only initialize plugins when listing installed plugins
|
||||||
|
if argv[i+1] != "list"
|
||||||
|
ENV['VAGRANT_DISABLE_PLUGIN_INIT'] = "1"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
|
@ -288,7 +288,7 @@ end
|
||||||
if Vagrant.plugins_init?
|
if Vagrant.plugins_init?
|
||||||
begin
|
begin
|
||||||
Vagrant::Bundler.instance.init!(plugins)
|
Vagrant::Bundler.instance.init!(plugins)
|
||||||
rescue Exception => e
|
rescue StandardError, ScriptError => e
|
||||||
global_logger.error("Plugin initialization error - #{e.class}: #{e}")
|
global_logger.error("Plugin initialization error - #{e.class}: #{e}")
|
||||||
e.backtrace.each do |backtrace_line|
|
e.backtrace.each do |backtrace_line|
|
||||||
global_logger.debug(backtrace_line)
|
global_logger.debug(backtrace_line)
|
||||||
|
@ -334,18 +334,16 @@ if Vagrant.plugins_enabled?
|
||||||
plugins.each do |plugin_name, plugin_info|
|
plugins.each do |plugin_name, plugin_info|
|
||||||
if plugin_info["require"].to_s.empty?
|
if plugin_info["require"].to_s.empty?
|
||||||
begin
|
begin
|
||||||
global_logger.debug("Loading plugin `#{plugin_name}` with default require: `#{plugin_name}`")
|
global_logger.info("Loading plugin `#{plugin_name}` with default require: `#{plugin_name}`")
|
||||||
require plugin_name
|
require plugin_name
|
||||||
rescue LoadError, Gem::LoadError => load_error
|
rescue LoadError => err
|
||||||
if plugin_name.include?("-")
|
if plugin_name.include?("-")
|
||||||
begin
|
plugin_slash = plugin_name.gsub("-", "/")
|
||||||
plugin_slash = plugin_name.gsub("-", "/")
|
global_logger.error("Failed to load plugin `#{plugin_name}` with default require. - #{err.class}: #{err}")
|
||||||
global_logger.debug("Failed to load plugin `#{plugin_name}` with default require.")
|
global_logger.info("Loading plugin `#{plugin_name}` with slash require: `#{plugin_slash}`")
|
||||||
global_logger.debug("Loading plugin `#{plugin_name}` with slash require: `#{plugin_slash}`")
|
require plugin_slash
|
||||||
require plugin_slash
|
else
|
||||||
rescue LoadError, Gem::LoadError
|
raise
|
||||||
global_logger.warn("Failed to load plugin `#{plugin_name}`. Assuming library and moving on.")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -358,12 +356,12 @@ if Vagrant.plugins_enabled?
|
||||||
global_logger.debug("Bundler detected in use. Loading `:plugins` group.")
|
global_logger.debug("Bundler detected in use. Loading `:plugins` group.")
|
||||||
::Bundler.require(:plugins)
|
::Bundler.require(:plugins)
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue ScriptError, StandardError => err
|
||||||
global_logger.error("Plugin loading error: #{e.class} - #{e}")
|
global_logger.error("Plugin loading error: #{err.class} - #{err}")
|
||||||
e.backtrace.each do |backtrace_line|
|
err.backtrace.each do |backtrace_line|
|
||||||
global_logger.debug(backtrace_line)
|
global_logger.debug(backtrace_line)
|
||||||
end
|
end
|
||||||
raise Vagrant::Errors::PluginLoadError, message: e.to_s
|
raise Vagrant::Errors::PluginLoadError, message: err.to_s
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
global_logger.debug("Plugin loading is currently disabled.")
|
global_logger.debug("Plugin loading is currently disabled.")
|
||||||
|
|
|
@ -303,6 +303,15 @@ module Vagrant
|
||||||
solution = request_set.resolve(installer_set)
|
solution = request_set.resolve(installer_set)
|
||||||
activate_solution(solution)
|
activate_solution(solution)
|
||||||
|
|
||||||
|
# Remove gems which are already installed
|
||||||
|
request_set.sorted_requests.delete_if do |activation_req|
|
||||||
|
rs_spec = activation_req.spec
|
||||||
|
if vagrant_internal_specs.detect{|ispec| ispec.name == rs_spec.name && ispec.version == rs_spec.version }
|
||||||
|
@logger.debug("Removing activation request from install. Already installed. (#{rs_spec.spec.full_name})")
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@logger.debug("Installing required gems.")
|
@logger.debug("Installing required gems.")
|
||||||
|
|
||||||
# Install all remote gems into plugin path. Set the installer to ignore dependencies
|
# Install all remote gems into plugin path. Set the installer to ignore dependencies
|
||||||
|
|
Loading…
Reference in New Issue