From 5462ec27b8b36a35dbf830bc4edcbb15e9bc91e1 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Thu, 10 Jun 2010 14:48:34 -0700 Subject: [PATCH] Added check for stray 'config' scripts in $PATH. If the user has, for instance, a non-system "xml2-config" in the path ahead of the system and Homebrew folders, ./configure scripts which look for and use this config script will get confused. --- Library/Homebrew/brew_doctor.rb | 37 ++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/brew_doctor.rb b/Library/Homebrew/brew_doctor.rb index aca8caab71..7aa6c616d5 100644 --- a/Library/Homebrew/brew_doctor.rb +++ b/Library/Homebrew/brew_doctor.rb @@ -225,13 +225,47 @@ def check_for_gettext end end +def check_for_config_scripts + real_cellar = HOMEBREW_CELLAR.realpath + + config_scripts = [] + + paths = ENV['PATH'].split(':').collect{|p| File.expand_path p} + paths.each do |p| + next if ['/usr/bin', '/usr/sbin', '/usr/X11/bin', "#{HOMEBREW_PREFIX}/bin", "#{HOMEBREW_PREFIX}/sbin"].include? p + next if %r[^(#{real_cellar.to_s}|#{HOMEBREW_CELLAR.to_s})] =~ p + + configs = Dir["#{p}/*-config"] + # puts "#{p}\n #{configs * ' '}" unless configs.empty? + config_scripts << [p, configs.collect {|p| File.basename(p)}] unless configs.empty? + end + + unless config_scripts.empty? + puts <<-EOS.undent + Some "config" scripts were found in your path, but not in system or Homebrew folders. + + `./configure` scripts often look for *-config scripts to determine if software packages + are installed, and what additional flags to use when compiling and linking. + + Having additional scripts in your path can confuse software installed via Homebrew if + the config script overrides a system or Homebrew provided script of the same name. + + EOS + + config_scripts.each do |pair| + puts pair[0] + puts " " + pair[1] * " " + end + end +end + def brew_doctor read, write = IO.pipe if fork == nil read.close $stdout.reopen write - + check_usr_bin_ruby check_homebrew_prefix check_for_stray_dylibs @@ -243,6 +277,7 @@ def brew_doctor check_which_pkg_config check_pkg_config_paths check_for_gettext + check_for_config_scripts exit! 0 else