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.
This commit is contained in:
Max Howell 2011-08-31 15:38:11 +01:00
parent 0aca152f23
commit bfabfe77dd

View File

@ -319,25 +319,29 @@ def check_user_path
seen_prefix_sbin = false seen_prefix_sbin = false
seen_usr_bin = false seen_usr_bin = false
path_folders.each do |p| path_folders.each do |p| case p
if p == '/usr/bin' when '/usr/bin'
seen_usr_bin = true seen_usr_bin = true
unless seen_prefix_bin unless seen_prefix_bin
# 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 puts <<-EOS.undent
/usr/bin is in your PATH before Homebrew's bin. This means that system- This means that system-provided programs will be used instead of those
provided programs will be used before Homebrew-provided ones. This is an provided by Homebrew. This is an issue if you eg. brew installed Python.
issue if you install, for instance, Python.
Consider editing your .bashrc to put: Consider editing your .bashrc to put:
#{HOMEBREW_PREFIX}/bin #{HOMEBREW_PREFIX}/bin
ahead of /usr/bin in your $PATH. ahead of /usr/bin in your $PATH.
EOS EOS
end end
end end
when "#{HOMEBREW_PREFIX}/bin"
seen_prefix_bin = true if p == "#{HOMEBREW_PREFIX}/bin" seen_prefix_bin = true
seen_prefix_sbin = true if p == "#{HOMEBREW_PREFIX}/sbin" when "#{HOMEBREW_PREFIX}/sbin"
seen_prefix_sbin = true
end
end end
unless seen_prefix_bin unless seen_prefix_bin