1

Ruby versions less than 2.3.1 fail to install when clang --version is 12 or greater. To reproduce the problem, first get xcode command line developer tools version 12 via software update or wipe your mac and install homebrew:

# homebrew installs version 12 of the command line developer tools as well
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Then this fails:

brew install rbenv
rbenv install 2.2.5

Output of rbenv install 2.2.5:

Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/kburnett/.rbenv/versions/2.2.5

Downloading ruby-2.2.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.5.tar.bz2
Installing ruby-2.2.5...

WARNING: ruby-2.2.5 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

ruby-build: using readline from homebrew

BUILD FAILED (Mac OS X 10.15.6 using ruby-build 20200819)

Inspect or clean up the working tree at /var/folders/my/qwq5ncb54svfh_qs70kjh4qc0000gn/T/ruby-build.20200921102602.41313.Eghhn7
Results logged to /var/folders/my/qwq5ncb54svfh_qs70kjh4qc0000gn/T/ruby-build.20200921102602.41313.log

Last 10 log lines:
compiling ../.././ext/psych/yaml/reader.c
compiling ../.././ext/psych/yaml/emitter.c
linking shared-object json/ext/generator.bundle
compiling ../.././ext/psych/yaml/parser.c
installing default psych libraries
linking shared-object bigdecimal.bundle
linking shared-object psych.bundle
linking shared-object nkf.bundle
linking shared-object date_core.bundle
make: *** [build-ext] Error 2

In the file where it says "Results logged to", it reports that there were 3 warnings and 4 errors. The errors are these:

 % grep "error:" /var/folders/my/qwq5ncb54svfh_qs70kjh4qc0000gn/T/ruby-build.20200921102602.41313.log
./openssl_missing.h:71:6: error: conflicting types for 'HMAC_CTX_copy'
./openssl_missing.h:95:5: error: conflicting types for 'EVP_CIPHER_CTX_copy'
./openssl_missing.h:173:5: error: conflicting types for 'BN_rand_range'
./openssl_missing.h:177:5: error: conflicting types for 'BN_pseudo_rand_range'

Gist of problem at https://gist.github.com/burnettk/04fb637c4ec18f621b2df500dbcec00e.

burnettk
  • 13,557
  • 4
  • 51
  • 52

2 Answers2

3

Burnettk is correct about changing the Xcode CommandLineTools to a version below 12, however there is no need to delete /Library/Developer/CommandLineTools, which may well cause you other issues in your environment if you use Xcode day to day.

First, open Xcode and go to Preferences > Locations, and check what options you have in the Command Line Tools drop down. If you have it available, select Xcode 11.x and then retry the install. Locations view with Xcode 11.7 command line tools selected

If you don't have that version available already, install the maximum version of "Command Line Tools" below 12.0 from https://developer.apple.com/downloads/. When you're done, pop back to the Locations preferences, and select the tools you just installed, then re-do your Ruby installation.

Josh Heald
  • 3,907
  • 28
  • 37
2

This broke with the Xcode 12 release (16 Sep 2020). To "fix" / work around the issue, f you already have clang --version reporting version 12 dot something, you can sudo rm -rf /Library/Developer/CommandLineTools and then go to https://developer.apple.com/downloads/, sign in with your Apple ID, and find "Command Line Tools for Xcode 11.5" or similar. Once clang --version is reporting 11 dot something, this should work again: rbenv install 2.2.5

This workaround was originally discovered by bfreezy at https://github.com/rbenv/ruby-build/issues/1353.

burnettk
  • 13,557
  • 4
  • 51
  • 52