Skip to content

Commit

Permalink
fix homebrew path when which() returns false (#13937)
Browse files Browse the repository at this point in the history
* fix homebrew path when which() returns false

Signed-off-by: Corey Hemminger <hemminger@hotmail.com>
  • Loading branch information
Stromweld committed Sep 20, 2023
1 parent 566ed40 commit ad619fc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/chef/mixin/homebrew_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ def homebrew_bin_path(brew_bin_path = nil)
if brew_bin_path && ::File.exist?(brew_bin_path)
brew_bin_path
else
brew_bin_path = [which("brew"), "/opt/homebrew/bin/brew", "/usr/local/bin/brew", "/home/linuxbrew/.linuxbrew/bin/brew"].uniq.select { |x| ::File.exist?(x) && ::File.executable?(x) }.first
brew_bin_path || nil
[which("brew"), "/opt/homebrew/bin/brew", "/usr/local/bin/brew", "/home/linuxbrew/.linuxbrew/bin/brew"].uniq.select do |x|
next if x == false

::File.exist?(x) && ::File.executable?(x)
end.first || nil
end
end

Expand Down

0 comments on commit ad619fc

Please sign in to comment.