From c843fd2f12cdff5d0309b1665bb5ad29ac1d8164 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 28 Oct 2017 19:48:21 +0100 Subject: requirement: prepend rather than append PATH. Otherwise this ends up behind e.g. `/usr/bin` so is pretty useless. --- Library/Homebrew/requirement.rb | 2 +- Library/Homebrew/test/requirement_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index a69c68466..c98ea95e8 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -95,7 +95,7 @@ class Requirement parent = satisfied_result_parent return unless parent return if PATH.new(ENV["PATH"]).include?(parent.to_s) - ENV.append_path("PATH", parent) + ENV.prepend_path("PATH", parent) end def env diff --git a/Library/Homebrew/test/requirement_spec.rb b/Library/Homebrew/test/requirement_spec.rb index 11a3da8f4..2d0d86c86 100644 --- a/Library/Homebrew/test/requirement_spec.rb +++ b/Library/Homebrew/test/requirement_spec.rb @@ -138,7 +138,7 @@ describe Requirement do end it "infers path from #satisfy result" do - expect(ENV).to receive(:append_path).with("PATH", Pathname.new("/foo/bar")) + expect(ENV).to receive(:prepend_path).with("PATH", Pathname.new("/foo/bar")) subject.satisfied? subject.modify_build_environment end -- cgit v1.2.3 From 5de7ec394bf9f24423e0b380b39c6c2801eca81e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 28 Oct 2017 19:58:58 +0100 Subject: requirement: don't add /usr/local/{bin,sbin}. This should be considered a requirement bug if it's added. --- Library/Homebrew/requirement.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library') diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index c98ea95e8..dfe68c19c 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -94,6 +94,7 @@ class Requirement # PATH. parent = satisfied_result_parent return unless parent + return if ["#{HOMEBREW_PREFIX}/bin", "#{HOMEBREW_PREFIX}/bin"].include?(parent.to_s) return if PATH.new(ENV["PATH"]).include?(parent.to_s) ENV.prepend_path("PATH", parent) end -- cgit v1.2.3 From f0b25b5482ba43611c77d94c2326c35f14b6de3d Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 28 Oct 2017 19:48:44 +0100 Subject: requirement: convert Cellar path to opt path. --- Library/Homebrew/requirement.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index dfe68c19c..95807d5ae 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -77,7 +77,11 @@ class Requirement def satisfied_result_parent return unless @satisfied_result.is_a?(Pathname) - @satisfied_result.resolved_path.parent + parent = @satisfied_result.resolved_path.parent + if parent.to_s =~ %r{^#{Regexp.escape(HOMEBREW_CELLAR)}/([\w+-.@]+)/[^/]+/(s?bin)/?$} + parent = HOMEBREW_PREFIX/"opt/#{Regexp.last_match(1)}/#{Regexp.last_match(2)}" + end + parent end # Overriding #modify_build_environment is deprecated. -- cgit v1.2.3 From 29f81812ccf78c85ddac931dcfea9bfc88af82db Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 28 Oct 2017 19:49:25 +0100 Subject: brew.rb: cleanup PATH setup. Avoid adding all the tap commands to the PATH when not necessary. --- Library/Homebrew/brew.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 2cc339a83..e21e0bbd4 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -50,11 +50,6 @@ begin path = PATH.new(ENV["PATH"]) homebrew_path = PATH.new(ENV["HOMEBREW_PATH"]) - # Add contributed commands to PATH before checking. - tap_cmds = Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd") - path.append(tap_cmds) - homebrew_path.append(tap_cmds) - # Add SCM wrappers. path.append(HOMEBREW_SHIMS_PATH/"scm") homebrew_path.append(HOMEBREW_SHIMS_PATH/"scm") @@ -93,8 +88,14 @@ begin system(HOMEBREW_BREW_FILE, "uninstall", "--force", "brew-cask") end - # External commands expect a normal PATH - ENV["PATH"] = homebrew_path unless internal_cmd + unless internal_cmd + # Add contributed commands to PATH before checking. + tap_cmds = Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd") + homebrew_path.append(tap_cmds) + + # External commands expect a normal PATH + ENV["PATH"] = homebrew_path + end if internal_cmd Homebrew.send cmd.to_s.tr("-", "_").downcase -- cgit v1.2.3