From: "alanwu (Alan Wu)" Date: 2022-06-27T02:31:44+00:00 Subject: [ruby-core:109058] [Ruby master Bug#18876] OpenSSL is not available with `--with-openssl-dir` Issue #18876 has been updated by alanwu (Alan Wu). Status changed from Feedback to Open I had some [issues](https://github.com/ruby/openssl/pull/520) building OpenSSL and the Ruby wrapper, but I was able to reproduce this problem. RubyGems sets an `autoload` for OpenSSL and then immediately triggers it with a `defined?`: ```ruby # from lib/rubygems/openssl.rb autoload :OpenSSL, "openssl" module Gem HAVE_OPENSSL = defined? OpenSSL::SSL # :nodoc: end ``` This exposes a behavior particular to the Ruby build configuration. It seems that `defined?(AutoLoadConstant)` returns `nil` as opposed to loading the file in other build configurations: ```shell $ ruby --disable-all -ve 'autoload(:Ripper, "ripper"); p defined?(Ripper)' ruby 3.2.0dev (2022-06-26T13:24:22Z static-ext-load-rel 49d5921550) [x86_64-darwin21] nil $ chruby 3.1.2 $ ruby --disable-all -ve 'autoload(:Ripper, "ripper"); p defined?(Ripper)' ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20] "constant" ``` I haven't investigated any deeper than this. As a workaround, you can try applying the following patch against 3.1.2; I'm able to run `gem install rubygems-update` with it. ```diff --- a/lib/rubygems/openssl.rb +++ b/lib/rubygems/openssl.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -autoload :OpenSSL, "openssl" +require "openssl" module Gem HAVE_OPENSSL = defined? OpenSSL::SSL # :nodoc: ``` ---------------------------------------- Bug #18876: OpenSSL is not available with `--with-openssl-dir` https://bugs.ruby-lang.org/issues/18876#change-98204 * Author: Gloomy_meng (Gloomy Meng) * Status: Open * Priority: Normal * ruby -v: 3.1.1 * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- i try use ruby + gem in my macos app with .a framework, i need install ruby in a custom location. so i make & make install openssl with this configure: ``` shell /usr/bin/perl Configure --prefix="......./local/dependencies" no-shared zlib darwin64-x86_64-cc ``` then make & make install ruby with this configure: ``` shell /bin/sh configure --prefix /Users/xxxxx/xxxx/local/bundle --with-openssl-dir="/Users/xxxxx/xxxx/local/dependencies" --enable-load-relative --with-static-linked-ext --disable-install-doc --with-out-ext="xxxxxx" ``` ------ because i need to isolated environment, so i make `bundle-env` file for run shell. and i uploaded bundle-env file ------ and update gem by local ``` shell destroot/bundle/bin/bundle-env gem install downloads/rubygems-update-3.3.15.gem --no-document --env-shebang ``` at last, run install alway got exception: ``` shell destroot/bundle/bin/bundle-env gem install xxxxxxx --version="xxxxxx" --no-document --env-shebang ERROR: While executing gem ... (Gem::Exception) OpenSSL is not available. Install OpenSSL and rebuild Ruby (preferred) or use non-HTTPS sources ``` at the same env, i tried some command, and i got the right version what i make install ``` shell destroot/bundle/bin/bundle-env ruby --version // ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-darwin21] destroot/bundle/bin/bundle-env gem --version // 3.3.15 destroot/bundle/bin/bundle-env ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION' // OpenSSL 1.1.1i 8 Dec 2020 ``` ------ i found and uploaded `ext/openssl/mkmf.log` and ---Files-------------------------------- bundle-env (852 Bytes) mkmf.log (215 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: