ruby-build: Ruby 2.4.1 build failed on macOS Sierra 10.12.3

Ruby 2.4.1 build fails on macOS Sierra 10.12.3, below the log I got

rbenv install 2.4.1
ruby-build: use openssl from homebrew
Downloading ruby-2.4.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2
Installing ruby-2.4.1...

BUILD FAILED (OS X 10.12.3 using ruby-build 20170201)

Inspect or clean up the working tree at /var/folders/j2/90b3sd_j3fqcgc2yxp_wwc600000gq/T/ruby-build.20170326214012.36750
Results logged to /var/folders/j2/90b3sd_j3fqcgc2yxp_wwc600000gq/T/ruby-build.20170326214012.36750.log

Last 10 log lines:
../.././include/ruby/ruby.h:2166:6: note: expanded from macro 'rb_scan_args_count_block'
     rb_scan_args_count_end(fmt, ofs, varc, vari) : \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../.././include/ruby/ruby.h:2162:12: note: expanded from macro 'rb_scan_args_count_end'
    ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt)))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 warnings and 1 error generated.
make[2]: *** [ossl_x509store.o] Error 1
make[1]: *** [ext/openssl/all] Error 2
make: *** [build-ext] Error 2

cat /var/folders/j2/90b3sd_j3fqcgc2yxp_wwc600000gq/T/ruby-build.20170326214012.36750.log | grep -i error
checking for ERRORFUNC function attribute... x
checking for strerror... yes
	CFLAGS = -O3 -Wno-error=shorten-64-to-32  -pipe
compiling error.c
compiling regerror.c
compiling dataerror.c
ossl_x509store.c:175:16: error: member reference type 'int' is not a pointer
13 warnings and 1 error generated.
make[2]: *** [ossl_x509store.o] Error 1
make[1]: *** [ext/openssl/all] Error 2
make: *** [build-ext] Error 2

my openssl is the latest:

brew info openssl
openssl: stable 1.0.2k (bottled) [keg-only]
SSL/TLS cryptography library
https://openssl.org/
/usr/local/Cellar/openssl/1.0.2d_1 (1,638 files, 12.1M)
  Poured from bottle on 2015-07-13 at 20:46:23
/usr/local/Cellar/openssl/1.0.2k (1,696 files, 12M)
  Poured from bottle on 2017-02-03 at 07:32:39
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/openssl.rb
==> Dependencies
Build: makedepend ✘
==> Options
--universal
	Build a universal binary
--without-test
	Skip build-time tests (not recommended)
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

brew upgrade openssl
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
bash-git-prompt                                              checkstyle                                                   idris

Error: openssl 1.0.2k already installed

Any suggestion?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 23 (4 by maintainers)

Most upvoted comments

I had same issue after migration to new macbook pro using peer to peer migration, looks like Homebrew env crashed. I fixed it by delete the brew include files: sudo mv /usr/local/include /usr/local/include_old

I fixed my issue. It was because of a leftover openssl install, plus some missing ENV variables that appeared in later brew openssl versions. In any case:

  1. brew update
  2. brew unlink openssl
  3. brew uninstall --ignore-dependencies openssl
  4. Repeat 2. until openssl is completely nuked
  5. brew install openssl
  6. Follow post install instructions:
    If you need to have this software first in your PATH run:
      echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc
    
    For compilers to find this software you may need to set:
        LDFLAGS:  -L/usr/local/opt/openssl/lib
        CPPFLAGS: -I/usr/local/opt/openssl/include
    For pkg-config to find this software you may need to set:
        PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
    
  7. Profit! rbenv install 2.4.1

Thanks everyone for sharing your workarounds!

Closing due to staleness. Hopefully people don’t have this problem anymore.

I was having the same issue.

MacOS Version 10.13.2 (17C88) Ruby 2.4.2 OpenSSL 1.0.2n

I resolved with

brew update && brew upgrade openssl
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
brew upgrade ruby-build
rbenv install 2.4.2

https://github.com/Homebrew/brew/pull/597

Here is the solution!!! It works for me! brew update brew install openssl ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/ ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/ ln -s /usr/local/Cellar/openssl/1.0.2j/bin/openssl openssl ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/dotnet

even after using @mwxclauss solution (and @shuriu), you will probably still get BUILD ERROR with line like

SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

The reason is because rbenv still use old system “curl”, which knows nothing about your new “openssl v 1.1” (I used brew install openssl@1.1). For me, installing new version of curl with brew did the work:

brew install curl

Then add installed curl to your PATH (before default path, which is /usr/bin), and ensure that openssl of actual brew’s version is also there:

export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export PATH="/usr/local/opt/curl/bin:$PATH"

You can make sure after relaunch of terminal that latest versions of this programs will be used by trying

which -a openssl
which -a curl
openssl version -a
curl -V

First two commands should output all paths with the programs, but top ones should be brew versions. Last two commands should show latest versions of programs (1.1.0f and 7.55 for me now).

Struggling with getting rbenv up and running on my mac:

macOS 10.13.2 rbenv 1.1.1 OpenSSL 1.1.0g 2 Nov 2017 curl 7.57.0

% which rbenv
/usr/local/bin/rbenv
% which openssl
/usr/local/opt/openssl@1.1/bin/openssl
% which curl
/usr/local/opt/curl/bin/curl

rbenv, curl, openssl - all in PATH

% rbenv install 2.4.1
ruby-build: use openssl from homebrew
Downloading ruby-2.4.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2
Installing ruby-2.4.1...

BUILD FAILED (OS X 10.13.2 using ruby-build 20171215)

Inspect or clean up the working tree at /var/folders/31/41tck3qx69scnynksxc_38ch0000gn/T/ruby-build.20171220150125.94300
Results logged to /var/folders/31/41tck3qx69scnynksxc_38ch0000gn/T/ruby-build.20171220150125.94300.log

Last 10 log lines:
checking for long long... yes
checking for off_t... yes
checking char bit... 8
checking size of int... 0
checking size of short... 0
checking size of long... 0
checking size of long long... configure: error: in `/var/folders/31/41tck3qx69scnynksxc_38ch0000gn/T/ruby-build.20171220150125.94300/ruby-2.4.1':
configure: error: cannot compute sizeof (long long)
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.

Tried all solutions listed above - nothing helped. Any suggestion?

I was Unable to install ruby 2.4.1 with openssl but I I was able to install with openssl@1.1

  1. brew uninstall openssl --ignore-dependencies I had a 1.0.1l version.
  2. brew cleanup
  3. brew install openssl@1.1 installed openssl@1.1: stable 1.1.0f (bottled) [keg-only]
  4. export PATH="/usr/local/opt/openssl@1.1/bin:$PATH" in my ~/.bashrc file
  5. rbenv install 2.4.1 (previously upgraded ruby-build)

It seems the install downloaded openssl as part of ruby installation. Does that mean ruby-build did not use the openssl@1.1 installed in previous step?

My install output shows

$ rbenv install 2.4.1
Downloading openssl-1.1.0f.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/12f746f3f2493b2f39da7ecf63d7ee19c6ac9ec6a4fcd8c229da8a522cb12765
Installing openssl-1.1.0f...
Installed openssl-1.1.0f to /Users/marekj/.rbenv/versions/2.4.1

Downloading ruby-2.4.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2
Installing ruby-2.4.1...
ruby-build: use readline from homebrew
Installed ruby-2.4.1 to /Users/marekj/.rbenv/versions/2.4.1

When I type brew missing I still see I am missing openssl even if I have openssl@1.1 installed and PATH to it set.

$ brew missing
libevent: openssl
libssh: openssl
libssh2: openssl
mongodb: openssl
nmap: openssl
openssl-osx-ca: openssl
phantomjs: openssl
postgresql: openssl
rbenv: openssl
ruby: openssl
ruby-build: openssl
tmate: openssl
tmux: openssl

@shuriu your solution worked for me. Thank You.