Skip to content

Commit 673d5a7

Browse files
authoredSep 6, 2021
Dynamically set Homebrew-installed OpenSSL flag (#1204)
This is a follow-up to #1135 which added the OpenSSL flag assuming that if the `RUBY_PLATFORM` is `darwin` (macOS): - Homebrew is installed - OpenSSL is installed via Homebrew This PR: - no longer assumes Homebrew is installed if we're on macOS - no longer assumes OpenSSL is installed via Homebrew - asks Homebrew for the openssl location (which will also work with the newer openssl@1.1 recipe) Should prevent issues like these when running bundle install on the rails codebase: Bundle Install error due to: ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib'
1 parent ef28e60 commit 673d5a7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎ext/mysql2/extconf.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ def add_ssl_defines(header)
2222
end
2323

2424
# Homebrew openssl
25-
$LDFLAGS << ' -L/usr/local/opt/openssl/lib' if RUBY_PLATFORM =~ /darwin/
25+
if RUBY_PLATFORM =~ /darwin/ && system("command -v brew")
26+
openssl_location = `brew --prefix openssl`.strip
27+
if openssl_location
28+
$LDFLAGS << " -L#{openssl_location}/lib"
29+
end
30+
end
2631

2732
# 2.1+
2833
have_func('rb_absint_size')

0 commit comments

Comments
 (0)
Please sign in to comment.