diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb index b2e56f8cf2..a30a82b807 100644 --- a/Library/Homebrew/brew.h.rb +++ b/Library/Homebrew/brew.h.rb @@ -228,21 +228,40 @@ def diy end -def fix_PATH - bad_paths = `/usr/bin/which -a port`.split - bad_paths += `/usr/bin/which -a fink`.split - - # don't remove standard paths! - bad_paths.delete_if do |pn| - %w[/usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/X11/bin].include? pn or pn.empty? +def warn_about_macports_or_fink + # See these issues for some history: + # http://github.com/mxcl/homebrew/issues/#issue/13 + # http://github.com/mxcl/homebrew/issues/#issue/48 + + %w[port fink].each do |ponk| + path = `/usr/bin/which -s #{ponk}` + unless path.empty? + opoo "It appears you have Macports or Fink in your PATH" + puts "If formula fail to build try renaming or uninstalling these tools." + end end - bad_paths += %w[/opt/local/bin /opt/local/sbin /sw/bin /sw/sbin] - - paths = ENV['PATH'].split(':').reject do |p| - p.squeeze! '/' - bad_paths.find { |pn| p =~ /^#{pn}/ } and true + + # we do the above check because macports can be relocated and fink may be + # able to be relocated in the future. This following check is because if + # fink and macports are not in the PATH but are still installed it can + # *still* break the build -- because some build scripts hardcode these paths: + %w[/sw/bin/fink /opt/local/bin/port].each do |ponk| + if File.exist? ponk + opoo "It appears you have MacPorts or Fink installed" + puts "If formula fail to build, consider renaming: %s" % Pathname.new(ponk).dirname.parent + end + end + + # finally sometimes people make their MacPorts or Fink read-only so they + # can quickly test Homebrew out, but still in theory obey the README's + # advise to rename the root directory. This doesn't work, many build scripts + # error out when they try to read from these now unreadable directories. + %w[/sw /opt/local].each do |path| + if File.exist? path and not File.readable? path + opoo "It appears you have MacPorts or Fink installed" + puts "This has been known to cause build fails and other more subtle problems." + end end - ENV['PATH'] = paths*':' end diff --git a/bin/brew b/bin/brew index 00a7e4391c..85c2e1b333 100755 --- a/bin/brew +++ b/bin/brew @@ -12,11 +12,6 @@ if %w[/ /usr].include? HOMEBREW_PREFIX.to_s then abort <<-EOS EOS end -# remove MacPorts and Fink from the PATH, this prevents issues like: -# http://github.com/mxcl/homebrew/issues/#issue/13 -# http://github.com/mxcl/homebrew/issues/#issue/48 -fix_PATH - if MACOS_VERSION < 10.5 onoe "Homebrew currently requires Leopard or higher" abort "Sorry about that, but thanks for your interest anyway!" @@ -95,6 +90,8 @@ begin raise "Interactive mode can only be used with one formula argument" end + warn_about_macports_or_fink # keep warning before dependency resolution + unless ARGV.force? unless system "/usr/bin/which -s #{ENV.cc}" raise "We cannot find a c compiler, have you installed the latest Xcode?"