ruby-install icon indicating copy to clipboard operation
ruby-install copied to clipboard

Failing to compile Ruby 3.0.0

Open jspawar opened this issue 3 years ago • 3 comments

Hello friends,

I keep getting segfaults when trying to install Ruby 3 via ruby-install ruby (or ruby-install ruby --latest) with the following output (cropped of course):

...
assembling coroutine/amd64/Context.S
compiling enc/ascii.c
compiling enc/us_ascii.c
compiling enc/unicode.c
compiling enc/utf_8.c
compiling enc/trans/newline.c
compiling ./missing/explicit_bzero.c
compiling ./missing/setproctitle.c
compiling addr2line.c
compiling dmyenc.c
linking miniruby
config.status: creating ruby-runner.h
make: *** [exe/ruby] Segmentation fault: 11
make: *** Deleting file `exe/ruby'
!!! Compiling ruby 3.0.0 failed!

For whatever it's worth, here's some info about my environment:

# MacOS: 10.15.3

$ brew --version
Homebrew 2.7.7
Homebrew/homebrew-core (git revision bedb5; last commit 2021-01-29)
Homebrew/homebrew-cask (git revision 3d72f8; last commit 2021-01-29)

$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

$ ruby-install --version
ruby-install: 0.8.1

Am I missing some requirements or do I have incompatible versions of dependencies? (Would be surprised by the latter since that implies the Homebrew formula for Ruby doesn't actually/correctly list or fetch the dependencies it needs)

Thanks y'all

jspawar avatar Jan 29 '21 18:01 jspawar

I have exact same issues, Does any one knowwhat happen? and what should we do?

hadivarp avatar May 08 '21 11:05 hadivarp

Can this be reproduced by compiling ruby-3.0.0 manually?

wget https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.xz
tar -xJvf ruby-3.0.0.tar.xz
cd ruby-3.0.0
./configure --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml):$(brew --prefix gdbm)"
make

If so, this may be an upstream incompatibility bug.

postmodern avatar Jul 04 '21 21:07 postmodern

Had the same "Compiling ruby failed" issued. Turns out it is because the ruby installation does not work with openssl3.

Solution

  1. Check if you have openssl1.1 already installed via hombrew. If not, then install it as follows
  1. Now install ruby by providing the path to openssl1.1

You can also get the path to the install openssl as follow

sabinbajracharya avatar May 10 '22 21:05 sabinbajracharya

I can reliably reproduce a failure to install 3.0.0. But installing 3.2.0 works fine. Seeing as everyone in this issue was installing the latest version (ruby-install ruby), this should only affect the small subset of people who specifically need 3.0.0 for some reason.

vitorgalvao avatar Jan 08 '23 15:01 vitorgalvao

if you are doing this from rbenv:

RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/homebrew/[email protected]" rbenv install 2.6.7

andrewarrow avatar Aug 20 '23 18:08 andrewarrow

I have recently added some logic to dynamically install the [email protected] or openssl@3 homebrew package depending on the version of Ruby. See a37e332e055da91db5fb053a3d94ebb0f219043d This will be released shortly in ruby-install 0.9.3.

Also, ruby-install 0.9.3 now specifies --with-openssl-dir instead of just --with-opt-dir, which apparently Ruby's configure script treats with more precedence, and should prevent it from using another detected instance of openssl on the system.

However, this comes with a few caveats:

  1. This is risky, because openssl-1.1 has reached End-of-Life. It will not receive anymore security updates. While I understand people have legacy apps they must maintain, running old unmaintained versions of software is risky. I strongly recommend that people upgrade to at least Ruby 3.1, which uses openssl-3.0.
  2. This only works for homebrew users. Linux and other BSD package managers only provide one version of openssl, and that's most likely openssl-3.0, as openssl-1.1 has reached End-of-Life.
  3. I will eventually remove this complex logic after Ruby 3.0 reaches End-of-Life, which was the last Ruby version to use openssl-1.1. After that point, if users still need to install Ruby 2.7 or 3.0, they will have to specify -- --with-openssl-dir=/path/to/[email protected] themselves.

Comment or reopen this issue if you still have issues with ruby-install 0.9.3.

postmodern avatar Dec 01 '23 21:12 postmodern