diff options
| author | ilovezfs | 2017-03-10 07:28:55 -0800 |
|---|---|---|
| committer | ilovezfs | 2017-03-11 01:59:50 -0800 |
| commit | 76db07e1b5ef096317701a95285b04aa7bf83187 (patch) | |
| tree | 8cbebb8601f7cfbac530a99fe7d815c3fabcf42b /Library | |
| parent | 371a830028f53c0ac94d37b736307837b2f2b120 (diff) | |
| download | brew-76db07e1b5ef096317701a95285b04aa7bf83187.tar.bz2 | |
env: make prepend_path ignore system paths
`ENV.prepend_path "PATH", which("emacs").dirname` in the emacs
requirement was causing us to end up invoking /usr/bin/clang instead
of /usr/local/Homebrew/Library/Homebrew/shims/super/clang.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/extend/ENV/shared.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/test/ENV_spec.rb | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index 3b07e0a71..2cdc2f83a 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -87,7 +87,11 @@ module SharedEnvExtension # Is the formula struggling to find the pkgconfig file? Point it to it. # This is done automatically for `keg_only` formulae. # <pre>ENV.prepend_path "PKG_CONFIG_PATH", "#{Formula["glib"].opt_lib}/pkgconfig"</pre> + # Prepending a system path such as /usr/bin is a no-op so that requirements + # don't accidentally override superenv shims or formulae's `bin` directories + # (e.g. <pre>ENV.prepend_path "PATH", which("emacs").dirname</pre>) def prepend_path(key, path) + return if %w[/usr/bin /bin /usr/sbin /sbin].include? path.to_s prepend key, path, File::PATH_SEPARATOR if File.directory? path end diff --git a/Library/Homebrew/test/ENV_spec.rb b/Library/Homebrew/test/ENV_spec.rb index 7b50ca1d4..07f6cdb6b 100644 --- a/Library/Homebrew/test/ENV_spec.rb +++ b/Library/Homebrew/test/ENV_spec.rb @@ -115,11 +115,11 @@ shared_examples EnvActivation do describe "#prepend_path" do it "prepends to a path" do - subject.prepend_path "FOO", "/usr/bin" - expect(subject["FOO"]).to eq("/usr/bin") + subject.prepend_path "FOO", "/usr/libexec" + expect(subject["FOO"]).to eq("/usr/libexec") - subject.prepend_path "FOO", "/bin" - expect(subject["FOO"]).to eq("/bin#{File::PATH_SEPARATOR}/usr/bin") + subject.prepend_path "FOO", "/usr" + expect(subject["FOO"]).to eq("/usr#{File::PATH_SEPARATOR}/usr/libexec") end end |
