ruby-build: Ruby installation fails in macOS Catalina

EDIT: Solution in comment below


I’ve seen the other issues #1408 #1394 #1395 but the error I’m experiencing is slightly different. This happens on any version of ruby I try to install.

$ rbenv install 2.7.0

Downloading openssl-1.1.1d.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2
Installing openssl-1.1.1d...

BUILD FAILED (OS X 10.15.3 using ruby-build 20200224)

Inspect or clean up the working tree at /var/folders/s4/6_9qvyzn6kvcd2lz2jm3y_fw0000gq/T/ruby-build.20200303110227.33296.Nfnu5g
Results logged to /var/folders/s4/6_9qvyzn6kvcd2lz2jm3y_fw0000gq/T/ruby-build.20200303110227.33296.log

Last 10 log lines:
include/openssl/crypto.h:341:33: error: unknown type name 'time_t'; did you mean 'size_t'?
struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);
                                ^~~~~~
                                size_t
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_size_t.h:31:32: note: 'size_t' declared here
typedef __darwin_size_t        size_t;
                               ^
1 error generated.
make[1]: *** [apps/app_rand.o] Error 1
make: *** [all] Error 2

I’ve updated ruby-build and rbenv to the latest versions

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (3 by maintainers)

Most upvoted comments

I had this same issue with a recent install of Catalina and worked around it by ensuring that readline and openssl were both installed by homebrew and that my .zshrc was configured to include those libraries in my compiler flags.

First:

[~] brew install readline openssl

Then (via .zshrc):

# Setup Compiler paths for readline and openssl
local READLINE_PATH=$(brew --prefix readline)
local OPENSSL_PATH=$(brew --prefix openssl)
export LDFLAGS="-L$READLINE_PATH/lib -L$OPENSSL_PATH/lib"
export CPPFLAGS="-I$READLINE_PATH/include -I$OPENSSL_PATH/include"
export PKG_CONFIG_PATH="$READLINE_PATH/lib/pkgconfig:$OPENSSL_PATH/lib/pkgconfig"

# Use the OpenSSL from Homebrew instead of ruby-build
# Note: the Homebrew version gets updated, the ruby-build version doesn't
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$OPENSSL_PATH"

# Place openssl@1.1 at the beginning of your PATH (preempt system libs)
export PATH=$OPENSSL_PATH/bin:$PATH

# Load rbenv
eval "$(rbenv init -)"

# Extract the latest version of Ruby so you can do this:
# rbenv install $LATEST_RUBY_VERSION
export LATEST_RUBY_VERSION=$(rbenv install -l | grep -v - | tail -1)

Last:

[~] source .zshrc
[~] rbenv install $LATEST_RUBY_VERSION
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
ruby-build: using readline from homebrew
Installed ruby-2.7.1 to /Users/tobius/.rbenv/versions/2.7.1

For what it’s worth, the above solutions didn’t work to install Ruby 3.0 on macOS 11.1

sw_vers
ProductName:	macOS
ProductVersion:	11.1
BuildVersion:	20C69

rbenv install 3.0.0
Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.0.1 using ruby-build 20201225)

Inspect or clean up the working tree at /var/folders/sh/jqmw4djd1f7_5c2qr92cn1sw0000gn/T/ruby-build.20201225183431.58053.2gn6ht
Results logged to /var/folders/sh/jqmw4djd1f7_5c2qr92cn1sw0000gn/T/ruby-build.20201225183431.58053.log

Last 10 log lines:
In file included from compile.c:39:
./vm_callinfo.h:217:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
    if (debug) rp(ci);
               ^
./internal.h:95:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
2 errors generated.
make: *** [compile.o] Error 1
make: *** Waiting for unfinished jobs....

edit : Compilation succeeds with Xcode 12.3 and xcode-select version 2384 installed. ✅

rbenv install 3.0.0
Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
ruby-build: using readline from homebrew
Installed ruby-3.0.0 to /Users/frank/.rbenv/versions/3.0.0

As I mentioned on the other issue try following:

$ brew install openssl
$ export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
$ rbenv install 2.7.8

It should work (not tested on Catalina).

Updating of the command tools helped me:

sudo rm -rf /Library/Developer/CommandLineTools          
sudo xcode-select --install

For what it’s worth the above solutions didn’t work to install Ruby 3.0 on macOS 11.01

rbenv install 3.0.0
Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.0.1 using ruby-build 20201225)

Inspect or clean up the working tree at /var/folders/sh/jqmw4djd1f7_5c2qr92cn1sw0000gn/T/ruby-build.20201225183431.58053.2gn6ht
Results logged to /var/folders/sh/jqmw4djd1f7_5c2qr92cn1sw0000gn/T/ruby-build.20201225183431.58053.log

Last 10 log lines:
In file included from compile.c:39:
./vm_callinfo.h:217:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
    if (debug) rp(ci);
               ^
./internal.h:95:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
2 errors generated.
make: *** [compile.o] Error 1
make: *** Waiting for unfinished jobs....

same problem on OSX Catalina 10.15.7 error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'

@romicaiarca Hey man. What I ended up finding out is that 2.5.1 is not compatible with Big Sur or the M1 chip.

2.7.2+ is. I was able to download 2.7.2 and 3.0.0

see comments at: https://github.com/rbenv/ruby-build/issues/1705

Thank you @tobius, that worked perfectly

👏 bless you @pftg

That fix worked for me installing 2.7.5 on MacOS 12.0.1 Monterey after spending hours trying to reinstall ruby after messing up all my permissions/environment running sudo gem install bundler.

One thing to note is that my xcode-select version (2392) didn’t change so I guess the reinstall alone did the trick.

@DirtyF I went ahead and upgraded to macOS 11.1 and checked that xcode was at 2384. Any idea what else might be the issue? This is what is showed me:

erikschulte@Eriks-MacBook-Pro ~ % xcode-select -v xcode-select version 2384. erikschulte@Eriks-MacBook-Pro ~ % rbenv install 2.5.1 Downloading openssl-1.1.1i.tar.gz… -> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242 Installing openssl-1.1.1i… Installed openssl-1.1.1i to /Users/erikschulte/.rbenv/versions/2.5.1

Downloading ruby-2.5.1.tar.bz2… -> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.bz2 Installing ruby-2.5.1…

WARNING: ruby-2.5.1 is nearing its end of life. It only receives critical security updates, no bug fixes.

ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.1 using ruby-build 20201225)

Inspect or clean up the working tree at /var/folders/8q/3_kkmpr9335_5lbl29t0tnfh0000gn/T/ruby-build.20210112120819.73940.BmgW0u Results logged to /var/folders/8q/3_kkmpr9335_5lbl29t0tnfh0000gn/T/ruby-build.20210112120819.73940.log

Last 10 log lines: compiling …/…/./ext/psych/yaml/dumper.c compiling …/…/./ext/psych/yaml/reader.c compiling …/…/./ext/psych/yaml/emitter.c compiling …/…/./ext/psych/yaml/parser.c 5 warnings generated. linking shared-object date_core.bundle linking shared-object zlib.bundle 1 warning generated. linking shared-object psych.bundle make: *** [build-ext] Error 2

Huh, that’s weird. Why don’t you create a gist with your build log and post a link here?

I suspect you have stray headers in your /usr/local/include. What does brew doctor say? Search stack overflow and see if you can fix any complaints that it might throw and try again.