Merge pull request #3385 from MikeMcQuaid/path-fixes-cleanup
Fix and cleanup some PATH usage.
This commit is contained in:
commit
c6f40d5864
@ -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
|
||||
|
||||
@ -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.
|
||||
@ -94,8 +98,9 @@ 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.append_path("PATH", parent)
|
||||
ENV.prepend_path("PATH", parent)
|
||||
end
|
||||
|
||||
def env
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user