Skip to content

Commit 2f89b05

Browse files
committed
Properly handle multiple versions for internal specs
When building the internal specs collection, multiple specifications may exist due to default gems. When building the collection, always set the specification with the greater version. This change prevents multiple versions of the same gem attempting to be activated.
1 parent ffe76cb commit 2f89b05

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/vagrant/bundler.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,10 @@ def internal_install(plugins, update, **extra)
549549
@logger.debug("Disabling strict dependency enforcement")
550550
end
551551

552-
@logger.debug("Dependency list for installation:\n - " \
553-
"#{plugin_deps.map{|d| "#{d.name} #{d.requirement}"}.join("\n - ")}")
552+
dep_list = plugin_deps.sort_by(&:name).map { |d|
553+
"#{d.name} #{d.requirement}"
554+
}.join("\n - ")
555+
@logger.debug("Dependency list for installation:\n - #{dep_list}")
554556

555557
all_sources = source_list.values.flatten.uniq
556558
default_sources = DEFAULT_GEM_SOURCES & all_sources
@@ -680,11 +682,11 @@ def vagrant_internal_specs
680682
directories = [spec_dir]
681683
if Vagrant.in_bundler?
682684
Gem::Specification.find_all{true}.each do |spec|
683-
list[spec.full_name] = spec
685+
list[spec.name] = spec
684686
end
685687
else
686688
builtin_specs.each do |spec|
687-
list[spec.full_name] = spec
689+
list[spec.name] = spec
688690
end
689691
end
690692
if Vagrant.in_installer?
@@ -693,8 +695,8 @@ def vagrant_internal_specs
693695
end
694696
end
695697
Gem::Specification.each_spec(directories) do |spec|
696-
if !list[spec.full_name]
697-
list[spec.full_name] = spec
698+
if !list[spec.name] || list[spec.name].version < spec.version
699+
list[spec.name] = spec
698700
end
699701
end
700702
list.values

0 commit comments

Comments
 (0)