aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2015-09-27 15:45:57 +0800
committerXu Cheng2015-09-28 21:47:04 +0800
commit767d9618247f9a8b8d2424d033042d54ddcd5c85 (patch)
tree30946801b5dae92ce145b52b37c2e98c26e540f4 /Library
parentb37a28514126ac46e06cc1f5c8cc124a0fdff7f1 (diff)
downloadbrew-767d9618247f9a8b8d2424d033042d54ddcd5c85.tar.bz2
ENV#userpaths!: ensure Superenv.bin and opt path come at first
This ensures that binaries in /usr/local/bin would not overwrite superenv. Closes Homebrew/homebrew#44376. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/ENV/shared.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index 875b0e98a..13241403c 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -190,10 +190,16 @@ module SharedEnvExtension
# @private
def userpaths!
- paths = ORIGINAL_PATHS.map { |p| p.realpath.to_s rescue nil } - %w[/usr/X11/bin /opt/X11/bin]
- self["PATH"] = paths.unshift(*self["PATH"].split(File::PATH_SEPARATOR)).uniq.join(File::PATH_SEPARATOR)
+ paths = self["PATH"].split(File::PATH_SEPARATOR)
+ # put Superenv.bin and opt path at the first
+ new_paths = paths.select { |p| p.start_with?("#{HOMEBREW_REPOSITORY}/Library/ENV") || p.start_with?("#{HOMEBREW_PREFIX}/opt") }
# XXX hot fix to prefer brewed stuff (e.g. python) over /usr/bin.
- prepend_path "PATH", HOMEBREW_PREFIX/"bin"
+ new_paths << "#{HOMEBREW_PREFIX}/bin"
+ # reset of self["PATH"]
+ new_paths += paths
+ # user paths
+ new_paths += ORIGINAL_PATHS.map { |p| p.realpath.to_s rescue nil } - %w[/usr/X11/bin /opt/X11/bin]
+ self["PATH"] = new_paths.uniq.join(File::PATH_SEPARATOR)
end
def fortran