summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2017-05-15 10:52:15 +0100
committerThom May <thom@chef.io>2017-05-16 11:01:15 +0100
commit48cd11446ab14c425b3da0fa744d4f4ed11b2f73 (patch)
treeaae649e65755ebbf83a433ee180c69aa756526f5 /lib/chef/provider
parent013d559b186e760f1f478180a15a5289f49e4849 (diff)
downloadchef-48cd11446ab14c425b3da0fa744d4f4ed11b2f73.tar.gz
Ensure that we check the embedded gem binary lasttm/gem_path
Previously we injected our expected paths in to ENV['PATH'] but we stopped doing that in Chef 13; for gem_package, we need to ensure that if all else fails we'll use the Omnibus provided gem binary, but we should never pick that if we can find a different one. Closes: #6103 Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/package/rubygems.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index 69936b3d58..161f790c31 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -21,6 +21,7 @@ require "uri"
require "chef/provider/package"
require "chef/resource/package"
require "chef/mixin/get_source_from_package"
+require "chef/mixin/which"
# Class methods on Gem are defined in rubygems
require "rubygems"
@@ -359,6 +360,7 @@ class Chef
provides :gem_package
include Chef::Mixin::GetSourceFromPackage
+ include Chef::Mixin::Which
def initialize(new_resource, run_context = nil)
super
@@ -410,11 +412,7 @@ class Chef
end
def find_gem_by_path
- Chef::Log.debug("#{new_resource} searching for 'gem' binary in path: #{ENV['PATH']}")
- separator = ::File::ALT_SEPARATOR ? ::File::ALT_SEPARATOR : ::File::SEPARATOR
- path_to_first_gem = ENV["PATH"].split(::File::PATH_SEPARATOR).find { |path| ::File.exist?(path + separator + "gem") }
- raise Chef::Exceptions::FileNotFound, "Unable to find 'gem' binary in path: #{ENV['PATH']}" if path_to_first_gem.nil?
- path_to_first_gem + separator + "gem"
+ which("gem", extra_path: RbConfig::CONFIG["bindir"])
end
def gem_dependency