rbenv / ruby-build

A tool to download, compile, and install Ruby on Unix-like systems.
https://rbenv.org/man/ruby-build.1
MIT License
3.89k stars 785 forks source link

Build failure of Ruby 3.3.1 and 3.3.2 on systems without openssl@1.1 #2400

Closed shigeya closed 5 months ago

shigeya commented 5 months ago

Steps to reproduce the behavior

With ruby-build 20240530.1

brew uninstall openssl@1.1

then,

rbenv install 3.3.1

or

rbenv install 3.3.2

Expected vs. actual behavior

I installed 3.3.2 with rbenv on one of my Macs, and it worked, but when I built 3.3.2 on another Mac, it failed. The logs showed that it was due to OpenSSL library directory, so I checked the differences and found that the Mac that succeeded had openssl@.1.1, while the one that failed did not.

In the one that failed, I successfully built 3.3.1 with ruby-build in the past and was using it. This time, when I uninstalled 3.3.1 and rebuilt it, it failed exactly the same way, so the cause seems to be somewhere in the build system.

Both environments are MacOS Sonoma latest M1.

Note: As a workaround, installing openssl@1.1 allows building 3.3.1/3.3.2 on the same machine.

I should provide PR, but I don't have time, so this is just a bug repo. Thank you for all your effort on ruby-build.

Logs

% rbenv install 3.3.1

==> Downloading ruby-3.3.1.tar.gz...
-> curl -q -fL -o ruby-3.3.1.tar.gz https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.1.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 21.0M  100 21.0M    0     0  4586k      0  0:00:04  0:00:04 --:--:-- 5069k
/var/folders/gy/1n9cs7jx0yg4h4s2790mx7jh0000gn/T/ruby-build.20240601072729.44822.PuA0zw/ruby-3.3.1
==> Installing ruby-3.3.1...
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.rbenv/versions/3.3.1" --enable-shared --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-gmp-dir=/opt/homebrew/opt/gmp --with-ext=openssl,psych,+ --with-openssl-dir=/opt/homebrew/opt/openssl@1.1
-> make -j 2
*** Following extensions are not compiled:
openssl:
    Could not be configured. It will not be installed.
    /private/var/folders/gy/1n9cs7jx0yg4h4s2790mx7jh0000gn/T/ruby-build.20240601072729.44822.PuA0zw/ruby-3.3.1/ext/openssl/extconf.rb:33: OpenSSL library directory could not be found in '/opt/homebrew/opt/openssl@1.1/lib'. You might want to fix this error in one of the following ways.
      * Recompile OpenSSL by configuring it with --libdir=lib  to specify the OpenSSL library directory.
      * Recompile Ruby by configuring it with --libdir=<dir> to specify the Ruby library directory.
      * Compile this openssl gem with --with-openssl-include=<dir> and --with-openssl-lib=<dir> options to specify the OpenSSL include and library directories.
    Check /var/folders/gy/1n9cs7jx0yg4h4s2790mx7jh0000gn/T/ruby-build.20240601072729.44822.PuA0zw/ruby-3.3.1/ext/openssl/mkmf.log for more details.

BUILD FAILED (macOS 14.5 on arm64 using ruby-build 20240530.1)

You can inspect the build directory at /var/folders/gy/1n9cs7jx0yg4h4s2790mx7jh0000gn/T/ruby-build.20240601072729.44822.PuA0zw
See the full build log at /var/folders/gy/1n9cs7jx0yg4h4s2790mx7jh0000gn/T/ruby-build.20240601072729.44822.log
shigeya commented 5 months ago

I forgot to mention that both of the systems with openssl@3 installed.

mislav commented 5 months ago

Thanks for the report. I'm looking at this line of output, which shows the configure invocation made by ruby-build:

-> ./configure "--prefix=$HOME/.rbenv/versions/3.3.1" --enable-shared --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-gmp-dir=/opt/homebrew/opt/gmp --with-ext=openssl,psych,+ --with-openssl-dir=/opt/homebrew/opt/openssl@1.1

I see --with-openssl-dir being passed, but if you said that the system had no openssl@1.1 at the time, then my main guess is that you might have had RUBY_CONFIGURE_OPTS environment variable with this flag in it. Many people set this environment variable globally in their shell initialization files but then forget about it.

Since recently, ruby-build is much better at detecting openssl versions installed on the system, particularly those from Homebrew, so manual intervention by explicitly setting --with-openssl-dir via environment variables or other means isn't necessary in most cases anymore.

shigeya commented 5 months ago

Ha! You're right. My apologies. It was staying in my shell configuration two years ago. Let me close this issue.

Again, thanks for the help!