Activate builtin specs during startup
When starting up, and before any loading, find our current
specification and activate all the internal dependencies
while also collecting the activated specifications. Store
these for later use when doing plugin resolutions. We bypass
the builtin list when running in bundler since they will
still show up as not activated, but we use the entire list
regardless.
This commit is contained in:
parent
282dadf784
commit
32f4951759
17
bin/vagrant
17
bin/vagrant
@ -84,20 +84,26 @@ $stderr.sync = true
|
||||
|
||||
# Before we start activate all our dependencies
|
||||
# so we can provide correct resolutions later
|
||||
builtin_specs = []
|
||||
|
||||
vagrant_spec = Gem::Specification.find_all_by_name("vagrant").detect do |spec|
|
||||
spec.version == Gem::Version.new(Vagrant::VERSION)
|
||||
end
|
||||
|
||||
dep_activator = proc do |spec|
|
||||
spec.runtime_dependencies.each do |dep|
|
||||
if gem(dep.name, *dep.requirement.as_list) || true
|
||||
dep_spec = Gem::Specification.find_all_by_name(dep.name).detect(&:activated?)
|
||||
dep_activator.call(dep_spec) if dep_spec
|
||||
gem(dep.name, *dep.requirement.as_list)
|
||||
dep_spec = Gem::Specification.find_all_by_name(dep.name).detect(&:activated?)
|
||||
if dep_spec
|
||||
builtin_specs << dep_spec
|
||||
dep_activator.call(dep_spec)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
dep_activator.call(vagrant_spec) if vagrant_spec
|
||||
if vagrant_spec
|
||||
dep_activator.call(vagrant_spec)
|
||||
end
|
||||
|
||||
env = nil
|
||||
begin
|
||||
@ -108,6 +114,9 @@ begin
|
||||
require 'vagrant/util/platform'
|
||||
require 'vagrant/util/experimental'
|
||||
|
||||
# Set our list of builtin specs
|
||||
Vagrant::Bundler.instance.builtin_specs = builtin_specs
|
||||
|
||||
# Schedule the cleanup of things
|
||||
at_exit(&Vagrant::Bundler.instance.method(:deinit))
|
||||
|
||||
|
||||
@ -189,6 +189,8 @@ module Vagrant
|
||||
attr_reader :env_plugin_gem_path
|
||||
# @return [Pathname] Vagrant environment data path
|
||||
attr_reader :environment_data_path
|
||||
# @return [Array<Gem::Specification>, nil] List of builtin specs
|
||||
attr_accessor :builtin_specs
|
||||
|
||||
def initialize
|
||||
@plugin_gem_path = Vagrant.user_data_path.join("gems", RUBY_VERSION).freeze
|
||||
@ -646,7 +648,6 @@ module Vagrant
|
||||
self_spec.activate
|
||||
@logger.info("Activated vagrant specification version - #{self_spec.version}")
|
||||
end
|
||||
self_spec.runtime_dependencies.each { |d| gem d.name, *d.requirement.as_list }
|
||||
# discover all the gems we have available
|
||||
list = {}
|
||||
if Gem.respond_to?(:default_specifications_dir)
|
||||
@ -660,7 +661,7 @@ module Vagrant
|
||||
list[spec.full_name] = spec
|
||||
end
|
||||
else
|
||||
Gem::Specification.find_all(&:activated?).each do |spec|
|
||||
builtin_specs.each do |spec|
|
||||
list[spec.full_name] = spec
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user