From bfabfe77dd1c6580d00e376a8cf62248aa18b460 Mon Sep 17 00:00:00 2001 From: Max Howell <max@methylblue.com> Date: Wed, 31 Aug 2011 15:38:11 +0100 Subject: [PATCH] Only report PATH order diagnosis if conflicts are found Rationale: brew doctor shouldn't give warnings for a default install. And this particular warning only applies for a small subset of formula: the ones that are "dupes". If we get reported issues that prove this was a mistake we will revert it. --- Library/Homebrew/cmd/doctor.rb | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb index 1fd78701c2..99cb221c68 100644 --- a/Library/Homebrew/cmd/doctor.rb +++ b/Library/Homebrew/cmd/doctor.rb @@ -319,25 +319,29 @@ def check_user_path seen_prefix_sbin = false seen_usr_bin = false - path_folders.each do |p| - if p == '/usr/bin' + path_folders.each do |p| case p + when '/usr/bin' seen_usr_bin = true unless seen_prefix_bin - puts <<-EOS.undent - /usr/bin is in your PATH before Homebrew's bin. This means that system- - provided programs will be used before Homebrew-provided ones. This is an - issue if you install, for instance, Python. - - Consider editing your .bashrc to put: - #{HOMEBREW_PREFIX}/bin - ahead of /usr/bin in your $PATH. - - EOS + # only show the doctor message if there are any conflicts + # rationale: a default install should not trigger any brew doctor messages + if Dir["#{HOMEBREW_PREFIX}/bin/*"].any? {|fn| File.exist? "/usr/bin/#{File.basename fn}"} + ohai "/usr/bin occurs before #{HOMEBREW_PREFIX}/bin" + puts <<-EOS.undent + This means that system-provided programs will be used instead of those + provided by Homebrew. This is an issue if you eg. brew installed Python. + + Consider editing your .bashrc to put: + #{HOMEBREW_PREFIX}/bin + ahead of /usr/bin in your $PATH. + EOS + end end + when "#{HOMEBREW_PREFIX}/bin" + seen_prefix_bin = true + when "#{HOMEBREW_PREFIX}/sbin" + seen_prefix_sbin = true end - - seen_prefix_bin = true if p == "#{HOMEBREW_PREFIX}/bin" - seen_prefix_sbin = true if p == "#{HOMEBREW_PREFIX}/sbin" end unless seen_prefix_bin -- GitLab