Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise an error when the specified OpenSSL library directory doesn't exist. #618

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions ext/openssl/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,32 @@

require "mkmf"

ssl_dirs = nil
if defined?(::TruffleRuby)
# Always respect the openssl prefix chosen by truffle/openssl-prefix
require 'truffle/openssl-prefix'
dir_config_given = dir_config("openssl", ENV["OPENSSL_PREFIX"]).any?
ssl_dirs = dir_config("openssl", ENV["OPENSSL_PREFIX"])
else
dir_config_given = dir_config("openssl").any?
ssl_dirs = dir_config("openssl")
end
dir_config_given = ssl_dirs.any?

_, ssl_ldir = ssl_dirs
if ssl_ldir&.split(File::PATH_SEPARATOR)&.none? { |dir| File.directory?(dir) }
# According to the `mkmf.rb#dir_config`, the `--with-openssl-dir=<dir>` uses
# the value of the `File.basename(RbConfig::MAKEFILE_CONFIG["libdir"])` as a
# loaded library directory name.
ruby_ldir_name = File.basename(RbConfig::MAKEFILE_CONFIG["libdir"])

raise "OpenSSL library directory could not be found in '#{ssl_ldir}'. " \
"You might want to fix this error in one of the following ways.\n" \
" * Recompile OpenSSL by configuring it with --libdir=#{ruby_ldir_name} " \
" to specify the OpenSSL library directory.\n" \
" * Recompile Ruby by configuring it with --libdir=<dir> to specify the " \
"Ruby library directory.\n" \
" * Compile this openssl gem with --with-openssl-include=<dir> and " \
"--with-openssl-lib=<dir> options to specify the OpenSSL include and " \
"library directories."
end
junaruga marked this conversation as resolved.
Show resolved Hide resolved

dir_config("kerberos")
Expand Down