From bcf0d6f2450cdea84a32f9a844307804f542fc21 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Sun, 23 Sep 2012 21:06:09 -0400 Subject: [PATCH] superenv: Remove HOMEBREW_PREFIX/bin from PATH We add the bins from all deps instead. Rationale: formula find and use eg. GNU-coreutils versions of things and then break. Only allow formula to use tools that they depend on and expect. I want to go further and only add include paths etc. for dependencies, I have done some work on this, but I fear it may be impossible. If an include path is eg. /usr/local/lib/foo/include, is it possible to know if this path is bad? Not always AFAICT. --- Library/Homebrew/build.rb | 1 + Library/Homebrew/cmd/sh.rb | 4 ++++ Library/Homebrew/superenv.rb | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index d3892819b0..80ad6f1594 100755 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -97,6 +97,7 @@ def install f if superenv? ENV.deps = keg_only_deps.map(&:to_s) + ENV.all_deps = f.recursive_deps.map(&:to_s) ENV.x11 = f.recursive_requirements.detect{|rq| rq.class == X11Dependency } ENV.setup_build_environment f.recursive_requirements.each { |rq| rq.modify_build_environment } diff --git a/Library/Homebrew/cmd/sh.rb b/Library/Homebrew/cmd/sh.rb index eca214e349..956cc4ecd1 100644 --- a/Library/Homebrew/cmd/sh.rb +++ b/Library/Homebrew/cmd/sh.rb @@ -8,6 +8,10 @@ module Homebrew extend self ENV.deps = Formula.installed.select{|f| f.keg_only? and f.opt_prefix.directory? }.map(&:name) end ENV.setup_build_environment + if superenv? + # superenv stopped adding brew's bin but generally user's will want it + ENV['PATH'] = ENV['PATH'].split(':').insert(1, "#{HOMEBREW_PREFIX}/bin").join(':') + end ENV['PS1'] = 'brew \[\033[1;32m\]\w\[\033[0m\]$ ' ENV['VERBOSE'] = '1' ENV['HOMEBREW_LOG'] = '1' diff --git a/Library/Homebrew/superenv.rb b/Library/Homebrew/superenv.rb index cefacdae39..7024affc60 100644 --- a/Library/Homebrew/superenv.rb +++ b/Library/Homebrew/superenv.rb @@ -23,6 +23,7 @@ end class << ENV attr :deps, true + attr :all_deps, true # above is just keg-only-deps attr :x11, true alias_method :x11?, :x11 @@ -104,8 +105,7 @@ class << ENV paths << "#{MacSystem.xcode43_developer_dir}/usr/bin" paths << "#{MacSystem.xcode43_developer_dir}/Toolchains/XcodeDefault.xctoolchain/usr/bin" end - paths += deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/bin" } - paths << HOMEBREW_PREFIX/:bin + paths += all_deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/bin" } paths << "#{MacSystem.x11_prefix}/bin" if x11? paths += %w{/usr/bin /bin /usr/sbin /sbin} paths.to_path_s @@ -256,6 +256,7 @@ if not superenv? ENV.prepend 'PATH', "#{HOMEBREW_PREFIX}/bin", ':' unless ORIGINAL_PATHS.include? HOMEBREW_PREFIX/'bin' else ENV.deps = [] + ENV.all_deps = [] end