aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2023-08-09 00:12:00 +0900
committerGitHub <noreply@github.com>2023-08-09 00:12:00 +0900
commit9391b568e1754d6f1c7b2ca6ad5e41cb0497d30c (patch)
tree11485d309857cfc83bd02323c2b0d7652f0907af
parentc5543a6aa0ff1487836c8da12fad5a11135482ed (diff)
parentca54087462b5bc48046974d40dc7cdf50da9619c (diff)
downloadruby-openssl-9391b568e1754d6f1c7b2ca6ad5e41cb0497d30c.tar.gz
Merge pull request #618 from junaruga/wip/check-ssl-lib-dir
Raise an error when the specified OpenSSL library directory doesn't exist.
-rw-r--r--ext/openssl/extconf.rb24
1 files changed, 22 insertions, 2 deletions
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index 368145d2..4bcf7b9c 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -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
dir_config("kerberos")