From 60b518278bdf1fffb46dc70c328041324955b684 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Fri, 29 Jun 2012 00:38:00 -0500 Subject: [PATCH] Refactor PATH setup - Make ORIGINAL_PATHS an array of Pathnames instead of strings - Append the dev tools path once in global.rb instead of build.rb Closes Homebrew/homebrew#13075. Signed-off-by: Jack Nagel --- Library/Homebrew/build.rb | 7 +------ Library/Homebrew/global.rb | 7 +++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index b237fc4470..271e7f141f 100755 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -4,8 +4,6 @@ # Rationale: Formula can use __END__, Formula can change ENV # Thrown exceptions are propogated back to the parent process over a pipe -ORIGINAL_PATHS = ENV['PATH'].split(':').map{ |p| File.expand_path p } - require 'global' at_exit do @@ -22,10 +20,7 @@ at_exit do ENV.extend(HomebrewEnvExtension) ENV.setup_build_environment # we must do this or tools like pkg-config won't get found by configure scripts etc. - ENV.prepend 'PATH', "#{HOMEBREW_PREFIX}/bin", ':' unless ORIGINAL_PATHS.include? "#{HOMEBREW_PREFIX}/bin" - # this is a safety measure for Xcode 4.3 which started not installing - # dev tools into /usr/bin as a default - ENV.prepend 'PATH', MacOS.dev_tools_path, ':' unless ORIGINAL_PATHS.include? MacOS.dev_tools_path + ENV.prepend 'PATH', "#{HOMEBREW_PREFIX}/bin", ':' unless ORIGINAL_PATHS.include? HOMEBREW_PREFIX/'bin' # Force any future invocations of sudo to require the user's password to be # re-entered. This is in-case any build script call sudo. Certainly this is diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 91821734a8..f403d67d22 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -92,7 +92,10 @@ unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT'] require 'compatibility' end -# For Xcode-only installs, we add the path of the included unix tools (like git) -if MacOS.dev_tools_path.to_s != '/usr/bin' +ORIGINAL_PATHS = ENV['PATH'].split(':').map{ |p| Pathname.new(File.expand_path(p)) } + +# Xcode-only installs place tools in non-standard locations, and we also want +# to ensure the dev tools are in the PATH in build.rb +unless ORIGINAL_PATHS.include? MacOS.dev_tools_path ENV['PATH'] = ENV['PATH'].to_s + ':' + MacOS.dev_tools_path end