diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 51a892e289..e1b1bb8ee8 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -434,7 +434,7 @@ module Homebrew message = "" - paths(ENV["HOMEBREW_PATH"]).each do |p| + paths.each do |p| case p when "/usr/bin" unless @seen_prefix_bin @@ -577,7 +577,7 @@ module Homebrew /Applications/Server.app/Contents/ServerRoot/usr/sbin ].map(&:downcase) - paths(ENV["HOMEBREW_PATH"]).each do |p| + paths.each do |p| next if whitelist.include?(p.downcase) || !File.directory?(p) realpath = Pathname.new(p).realpath.to_s @@ -1045,7 +1045,7 @@ module Homebrew end def check_for_external_cmd_name_conflict - cmds = paths.flat_map { |p| Dir["#{p}/brew-*"] }.uniq + cmds = Tap.cmd_directories.flat_map { |p| Dir["#{p}/brew-*"] }.uniq cmds = cmds.select { |cmd| File.file?(cmd) && File.executable?(cmd) } cmd_map = {} cmds.each do |cmd| diff --git a/Library/Homebrew/test/diagnostic_spec.rb b/Library/Homebrew/test/diagnostic_spec.rb index 8a25413ed4..f347010a93 100644 --- a/Library/Homebrew/test/diagnostic_spec.rb +++ b/Library/Homebrew/test/diagnostic_spec.rb @@ -194,7 +194,7 @@ describe Homebrew::Diagnostic::Checks do FileUtils.chmod 0755, cmd end - ENV["PATH"] = [path1, path2, ENV["PATH"]].join File::PATH_SEPARATOR + allow(Tap).to receive(:cmd_directories).and_return([path1, path2]) expect(subject.check_for_external_cmd_name_conflict) .to match("brew-foo") diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 1d16044dad..48ab94c4fb 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -420,8 +420,8 @@ def nostdout end end -def paths(env_path = ENV["PATH"]) - @paths ||= PATH.new(env_path).collect do |p| +def paths + @paths ||= PATH.new(ENV["HOMEBREW_PATH"]).collect do |p| begin File.expand_path(p).chomp("/") rescue ArgumentError