Merge pull request #10894 from chrisroberts/e-deps-system

Handle strict dependency enforcement when installed within system
This commit is contained in:
Chris Roberts 2019-06-05 14:00:07 -07:00 committed by GitHub
commit b90d01377e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 11 deletions

View File

@ -76,12 +76,8 @@ module Vagrant
# Add HashiCorp RubyGems source # Add HashiCorp RubyGems source
if !Gem.sources.include?(HASHICORP_GEMSTORE) if !Gem.sources.include?(HASHICORP_GEMSTORE)
current_sources = Gem.sources.sources.dup sources = [HASHICORP_GEMSTORE] + Gem.sources.sources
Gem.sources.clear Gem.sources.replace(sources)
Gem.sources << HASHICORP_GEMSTORE
current_sources.each do |src|
Gem.sources << src
end
end end
# Generate dependencies for all registered plugins # Generate dependencies for all registered plugins
@ -313,6 +309,12 @@ module Vagrant
@logger.debug("Enabling strict dependency enforcement") @logger.debug("Enabling strict dependency enforcement")
plugin_deps += vagrant_internal_specs.map do |spec| plugin_deps += vagrant_internal_specs.map do |spec|
next if system_plugins.include?(spec.name) next if system_plugins.include?(spec.name)
# If we are not running within the installer and
# we are not within a bundler environment then we
# only want activated specs
if !Vagrant.in_installer? && !Vagrant.in_bundler?
next if !spec.activated?
end
Gem::Dependency.new(spec.name, spec.version) Gem::Dependency.new(spec.name, spec.version)
end.compact end.compact
else else
@ -415,8 +417,13 @@ module Vagrant
Gem::Resolver.compose_sets(*sets) Gem::Resolver.compose_sets(*sets)
end end
# @return [Array<[Gem::Specification, String]>] spec and directory pairs # @return [Array<[Gem::Specification]>] spec list
def vagrant_internal_specs def vagrant_internal_specs
# activate any dependencies up front so we can always
# pin them when resolving
Gem::Specification.find { |s| s.name == "vagrant" && s.activated? }.
runtime_dependencies.each { |d| gem d.name, *d.requirement.as_list }
# discover all the gems we have available
list = {} list = {}
directories = [Gem::Specification.default_specifications_dir] directories = [Gem::Specification.default_specifications_dir]
Gem::Specification.find_all{true}.each do |spec| Gem::Specification.find_all{true}.each do |spec|

View File

@ -35,6 +35,14 @@ module Vagrant
!!ENV["VAGRANT_INSTALLER_ENV"] !!ENV["VAGRANT_INSTALLER_ENV"]
end end
# This returns a true/false if we are running within a bundler environment
#
# @return [Boolean]
def self.in_bundler?
!!ENV["BUNDLE_GEMFILE"] &&
!defined?(::Bundler).nil?
end
# Returns the path to the embedded directory of the Vagrant installer, # Returns the path to the embedded directory of the Vagrant installer,
# if there is one (if we're running in an installer). # if there is one (if we're running in an installer).
# #

View File

@ -706,10 +706,9 @@ en:
plugins in the `plugins` group in your Gemfile or manually require plugins in the `plugins` group in your Gemfile or manually require
them in a Vagrantfile. them in a Vagrantfile.
bundler_error: |- bundler_error: |-
Bundler, the underlying system Vagrant uses to install plugins, Vagrant failed to properly resolve required dependencies. These
reported an error. The error is shown below. These errors are usually errors can commonly be caused by misconfigured plugin installations
caused by misconfigured plugin installations or transient network or transient network issues. The reported error is:
issues. The error from Bundler is:
%{message} %{message}
cant_read_mac_addresses: |- cant_read_mac_addresses: |-