ruby-build: 2.7.2 won't install using Homebrew (macOS 10.15.7, Darwin 19.6.0)

Title says it all… I get a missing dependency error for libyaml (required to build the psych gem) even though libyaml is correctly installed:

$ brew install libyaml
Warning: libyaml 0.2.5 is already installed and up-to-date
To reinstall 0.2.5, run `brew reinstall libyaml`

$ brew reinstall libyaml
==> Downloading https://homebrew.bintray.com/bottles/libyaml-0.2.5.catalina.bott
######################################################################## 100.0%
==> Reinstalling libyaml 
==> Pouring libyaml-0.2.5.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/libyaml/0.2.5: 10 files, 323.5KB

$ brew cleanup

$ rbenv install 2.7.2
Downloading openssl-1.1.1g.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46
Installing openssl-1.1.1g...
Installed openssl-1.1.1g to /Users/stevewi/.rbenv/versions/2.7.2

Downloading ruby-2.7.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.bz2
Installing ruby-2.7.2...
ruby-build: using readline from homebrew

BUILD FAILED (Mac OS X 10.15.7 using ruby-build 20201005)

Inspect or clean up the working tree at /var/folders/pj/qdpn6dzn7ds24bpb6x0jmtcc0000gn/T/ruby-build.20201011092736.97275.wciA9q
Results logged to /var/folders/pj/qdpn6dzn7ds24bpb6x0jmtcc0000gn/T/ruby-build.20201011092736.97275.log

Last 10 log lines:
The Ruby yaml extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
  --prefix=/Users/stevewi/.rbenv/versions/2.7.2
  --with-openssl-dir=/Users/stevewi/.rbenv/versions/2.7.2/openssl
  --enable-shared
  --with-readline-dir=/usr/local/opt/readline
  CC=clang
  LDFLAGS=-L/Users/stevewi/.rbenv/versions/2.7.2/lib 
  CPPFLAGS=-I/Users/stevewi/.rbenv/versions/2.7.2/include 

rbenv.log

I filed this same defect on rbenv/rbenv…which was probably the wrong place… I couldn’t figure out how to move it here so the one on rbenv/rbenv. should probably be closed in favor of this one.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 26 (2 by maintainers)

Most upvoted comments

Another datapoint: I had the same problem except I’m using asdf to manage ruby versions. (asdf seems to use rbenv under the hood anyway.)

I tried RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl@1.1 --with-libyaml-dir=/usr/local/opt/libyaml" asdf install ruby 2.7.2 which failed

Downloading ruby-2.7.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.bz2
Installing ruby-2.7.2...
ruby-build: using readline from homebrew

BUILD FAILED (Mac OS X 10.15.7 using ruby-build 20201005)

Inspect or clean up the working tree at /var/folders/r6/35d6jll131j9s3q4yzvgxqqc0000gn/T/ruby-build.20201106122657.49603.Od1EaH
Results logged to /var/folders/r6/35d6jll131j9s3q4yzvgxqqc0000gn/T/ruby-build.20201106122657.49603.log

Last 10 log lines:
ERROR: Ruby install aborted due to missing extensions
Configure options used:
  --prefix=/Users/sebastiangeiger/.asdf/installs/ruby/2.7.2
  --with-openssl-dir=/usr/local/opt/openssl@1.1
  --with-libyaml-dir=/usr/local/opt/libyaml
  --enable-shared
  --with-readline-dir=/usr/local/opt/readline
  CC=clang
  LDFLAGS=-L/Users/sebastiangeiger/.asdf/installs/ruby/2.7.2/lib
  CPPFLAGS=-I/Users/sebastiangeiger/.asdf/installs/ruby/2.7.2/include

I then went into the folder that it told me in Inspect or clean up the working tree at /var/folders/r6/35d6jll131j9s3q4yzvgxqqc0000gn/T/ruby-build.20201106122657.49603.Od1EaH

In the folder I did:

$ ./configure --prefix=$HOME/.asdf/installs/ruby/2.7.2 \
                     --with-openssl-dir=/usr/local/opt/openssl@1.1 \
                     --enable-shared \
                     --with-readline-dir=/usr/local/opt/readline

followed by

make && make install

Additionally I had to do the following to get my project to build again

asdf reshim ruby 2.7.2
rm -rf ~/.gem
rm -rf ~/.gems
gem install bundler
bundle install
$ ~/.asdf/plugins/ruby/ruby-build/bin/ruby-build --version
ruby-build 20201005

ruby-2.7.2-install.log

Removing .gem:

rm -rf ~/.gem

allowed 2.7.2 to install successfully but I got the same error as before with 2.7.1.

A new version of ruby-build dropped today…20201118:

==> Summary
🍺  /usr/local/Cellar/ruby-build/20201118: 513 files, 255.7KB, built in 4 seconds
Removing: /usr/local/Cellar/ruby-build/20201117... (512 files, 255KB)
Removing: /Users/stevewi/Library/Caches/Homebrew/ruby-build--20201117.tar.gz... (67.6KB)

Here’s the results of the previous experiment with the new version:

rm -rf ~/.gem; rbenv install 2.7.0 -- failed
rm -rf ~/.gem; rbenv install 2.7.1  -- failed
rm -rf ~/.gem; rbenv install 2.7.2  -- succeeded
rm -rf ~/.gem; rbenv install 3.0.0-preview1  -- failed

The nature of the failure is the same as described in the OP.

A new version of ruby-build dropped today…20201117. Here’s the results of the previous experiment with the new version:

rm -rf ~/.gem; rbenv install 2.7.0 -- failed
rm -rf ~/.gem; rbenv install 2.7.1  -- failed
rm -rf ~/.gem; rbenv install 2.7.2  -- succeeded
rm -rf ~/.gem; rbenv install 3.0.0-preview1  -- failed

The nature of the failure is the same as described in the OP.

@yaroslav writes:

Nuking ~/.gem before rbenv install indeed solved it. Not sure if it is a tidy or proper way, or should be recommended at all, though.

Since it’s not reliable (see below); it doesn’t really matter “if it is a tidy or proper way, or should be recommended at all, though.” The only reliable way I’ve found to make this work is to extract it and configure/build it manually (as noted above).

@thewalkingtoast writes:

What about nuking the gem folder before each install?

Among recent ruby’s, 2.7.2 appears to be an anomaly. Here’s the results of my experiments:

rm -rf ~/.gem; rbenv install 2.7.0  -- failed
rm -rf ~/.gem; rbenv install 2.7.1  -- failed
rm -rf ~/.gem; rbenv install 2.7.2  -- succeeded
rm -rf ~/.gem; rbenv install 3.0.0-preview1  -- failed

IMHO, this kind of defeats the purpose of rbenv. It’s looking more and more like all this activity is going nowhere… Have any of the developers responded?