summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-04-07 11:23:41 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-04-07 11:23:41 -0700
commitfcbfe72f1178d308aef2a48cbcc55167f06f198e (patch)
treed5da41a1edec5202449c50ba5db02bafdbebb92d
parent5d1a312bbbfc651d4ee4dce1e8fe923002c8aaea (diff)
downloadchef-fcbfe72f1178d308aef2a48cbcc55167f06f198e.tar.gz
MVP to fix gem metadata command
simply use shell_out! to avoid bundler's state in the running chef-client process.
-rw-r--r--lib/chef/cookbook/gem_installer.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/chef/cookbook/gem_installer.rb b/lib/chef/cookbook/gem_installer.rb
index a85868ccfd..6957dc1077 100644
--- a/lib/chef/cookbook/gem_installer.rb
+++ b/lib/chef/cookbook/gem_installer.rb
@@ -15,12 +15,13 @@
# limitations under the License.
#
-require "bundler"
-require "bundler/inline"
+require "tmpdir"
+require "chef/mixin/shell_out"
class Chef
class Cookbook
class GemInstaller
+ include Chef::Mixin::ShellOut
# @return [Chef::EventDispatch::Dispatcher] the client event dispatcher
attr_accessor :events
@@ -45,10 +46,16 @@ class Chef
unless cookbook_gems.empty?
begin
- inline_gemfile do
- source Chef::Config[:rubygems_url]
- cookbook_gems.each do |args|
- gem(*args)
+ 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.map { |i| "'#{i}'" }.join(' ')}"
+ end
+ tf.close
+ Dir.chdir(dir) do
+ so = shell_out!("bundle install")
+ end
end
end
rescue Exception => e