diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/mixin/which.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/package/rubygems.rb | 8 |
2 files changed, 4 insertions, 6 deletions
diff --git a/lib/chef/mixin/which.rb b/lib/chef/mixin/which.rb index fd386241a0..8a825f55c9 100644 --- a/lib/chef/mixin/which.rb +++ b/lib/chef/mixin/which.rb @@ -25,7 +25,7 @@ class Chef def where(*cmds, extra_path: nil, &block) # NOTE: unnecessarily duplicates function of path_sanity extra_path ||= [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ] - paths = env_path.split(File::PATH_SEPARATOR) + extra_path + paths = env_path.split(File::PATH_SEPARATOR) + Array(extra_path) cmds.map do |cmd| paths.map do |path| filename = Chef.path_to(File.join(path, cmd)) 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 |