diff options
author | Maxime Brugidou <m.brugidou@criteo.com> | 2017-03-24 09:44:03 +0100 |
---|---|---|
committer | Maxime Brugidou <m.brugidou@criteo.com> | 2017-03-27 08:57:20 +0200 |
commit | b640eb8f3087b6c4ae56272ffb35b5918f0865d2 (patch) | |
tree | 6ae11a516bceeae8925826345c15c04ac4b0044b /lib | |
parent | 4a7d8849d14905a842fcec42322b30929f2ec995 (diff) | |
download | chef-b640eb8f3087b6c4ae56272ffb35b5918f0865d2.tar.gz |
Fix cookbook gem installer
Current gem installer does not work if multiple cookbook request the
same gem. The solution is to merge all the gem requirements for the same
gem.
If multiple cookbooks have conflicting constraints, the install will
fail anyway.
This bug affects Chef 12 too and make the feature almost unusable.
Change-Id: I73bdb3db94052dadc4bac7bf03f74db8c420aad5
Signed-off-by: Maxime Brugidou <m.brugidou@criteo.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/cookbook/gem_installer.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/chef/cookbook/gem_installer.rb b/lib/chef/cookbook/gem_installer.rb index df73ce3ee4..365b185426 100644 --- a/lib/chef/cookbook/gem_installer.rb +++ b/lib/chef/cookbook/gem_installer.rb @@ -36,10 +36,12 @@ class Chef # Installs the gems into the omnibus gemset. # def install - cookbook_gems = [] + cookbook_gems = Hash.new { |h, k| h[k] = [] } cookbook_collection.each do |cookbook_name, cookbook_version| - cookbook_gems += cookbook_version.metadata.gems + cookbook_version.metadata.gems.each do |args| + cookbook_gems[args.first] += args[1..-1] + end end events.cookbook_gem_start(cookbook_gems) @@ -49,8 +51,8 @@ class Chef Dir.mktmpdir("chef-gem-bundle") do |dir| File.open("#{dir}/Gemfile", "w+") do |tf| tf.puts "source '#{Chef::Config[:rubygems_url]}'" - cookbook_gems.each do |args| - tf.puts "gem(*#{args.inspect})" + cookbook_gems.each do |gem_name, args| + tf.puts "gem(*#{([gem_name] + args).inspect})" end tf.close Chef::Log.debug("generated Gemfile contents:") |