Skip to content

Commit 3b05154

Browse files
committed
[GR-18163] Avoid calling brew --prefix when Homebrew is in /usr/local (the default)
PullRequest: truffleruby/2438
2 parents 6024a6c + 819f388 commit 3b05154

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

lib/truffle/truffle/openssl-prefix.rb

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,32 @@
88

99
# Set OPENSSL_PREFIX in ENV to find the OpenSSL headers
1010

11+
search_homebrew = -> homebrew {
12+
if prefix = "#{homebrew}/opt/openssl@1.1" and Dir.exist?(prefix)
13+
prefix
14+
elsif prefix = "#{homebrew}/opt/openssl" and Dir.exist?(prefix)
15+
prefix
16+
end
17+
}
18+
1119
macOS = RUBY_PLATFORM.include?('darwin')
1220

1321
if macOS && !ENV['OPENSSL_PREFIX']
14-
homebrew = `brew --prefix 2>/dev/null`.strip
15-
unless $?.success? and !homebrew.empty? and Dir.exist?(homebrew)
16-
homebrew = nil
22+
if prefix = search_homebrew.call('/usr/local')
23+
# found
24+
else
25+
homebrew = `brew --prefix 2>/dev/null`.strip
26+
homebrew = nil unless $?.success? and !homebrew.empty? and Dir.exist?(homebrew)
27+
28+
if homebrew and prefix = search_homebrew.call(homebrew)
29+
# found
30+
elsif Dir.exist?('/opt/local/include/openssl') # MacPorts
31+
prefix = '/opt/local'
32+
end
1733
end
1834

19-
if homebrew and prefix = "#{homebrew}/opt/openssl@1.1" and Dir.exist?(prefix)
20-
ENV['OPENSSL_PREFIX'] = prefix
21-
elsif homebrew and prefix = "#{homebrew}/opt/openssl" and Dir.exist?(prefix)
35+
if prefix
2236
ENV['OPENSSL_PREFIX'] = prefix
23-
elsif Dir.exist?('/opt/local/include/openssl') # MacPorts
24-
ENV['OPENSSL_PREFIX'] = '/opt/local'
2537
else
2638
abort 'Could not find OpenSSL headers, install via Homebrew or MacPorts or set OPENSSL_PREFIX'
2739
end

0 commit comments

Comments
 (0)