Rbenv: Ruby 2.4.1 build failed on macOS High Sierra 10.13.2

Created on 21 Dec 2017  路  15Comments  路  Source: rbenv/rbenv

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 (tried different without specifying 1.1 as well)
curl 7.57.0

% which rbenv
/usr/local/bin/rbenv
% which openssl
/usr/local/opt/[email protected]/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?

Most helpful comment

I had the same issue and here is how I fixed it (thanks to a lot a googling)

$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

then follow the installation until the end (next, next, next,...)
and then install like you usually do:

$ rbenv install 2.5.5

All 15 comments

I'm experiencing nearly the same symptoms,

rbenv uninstall 2.4.1; rbenv install 2.4.1

rbenv: version `2.4.1' not installed
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...
ruby-build: use readline from homebrew

it will hang here indefinitely until I kill the process. readline 7.0.3_1 is already installed via homebrew

Did anyone find a solution for this? I'm getting same error

Getting the same issue too. Any luck, @GPreiss?

@briankabiro I tried what felt like everything (this might work for you, if it;s an rbenv issue, and you haven't tried it yet>>> https://github.com/rbenv/ruby-build/issues/377#issuecomment-310569462 . It didn't work for me though. ) In the end, I installed an Ubuntu environment via VirtualBox. It's not ideal, and I'm still looking for suggestions to make rbenv and ruby compatible with High Sierra, but it's a filler for now... Please let me know if you find anything that helps you!

Okay, no problem. I'll look into it and see. I'll also let you know if I find anything. 馃槂
This issue needs to be resolved ASAP.

@GPreiss solution with CONFIGURE_OPTS="--with-openssl-dir=brew --prefix openssl" rbenv install 2.3.4 didn't work for me as well :disappointed_relieved:

It looks like you're having problems with ruby-build, which is the plugin that provides rbenv-install.

  1. First, ensure that ruby-build is updated to the latest version.
  2. If your problem persists, check existing issues in the ruby-build repo and open a new one if necessary. When opening a new issue, please attach the full build log.

I have had the same issue but I am able to fix it by doing the following steps:

  1. sudo mv /usr/local/include /usr/local/include_old
  2. RUBY_CONFIGURE_OPTS="--disable-dtrace" rbenv install 2.4.1

I have had the same issue but I am able to fix it by doing the following steps:

  1. sudo mv /usr/local/include /usr/local/include_old
  2. RUBY_CONFIGURE_OPTS="--disable-dtrace" rbenv install 2.4.1

I was able to install Ruby 2.5.3 with this.
What next? Should I replace /usr/local/include_old to /usr/local/include after this?

I had the same issue:

rbenv install
rbenv: /Users/aaron/.rbenv/versions/2.5.5 already exists
continue with installation? (y/N) y
ruby-build: use openssl from homebrew
Downloading ruby-2.5.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.5.tar.bz2
Installing ruby-2.5.5...
ruby-build: use readline from homebrew

BUILD FAILED (OS X 10.14.3 using ruby-build 20190320)

Inspect or clean up the working tree at /var/folders/rc/m19n_3p91_s_l_ngjlpzq9zm0000gn/T/ruby-build.20190324233434.2007
Results logged to /var/folders/rc/m19n_3p91_s_l_ngjlpzq9zm0000gn/T/ruby-build.20190324233434.2007.log

... with the exact error being:

In file included from openssl_missing.c:21:
./openssl_missing.h:75:11: warning: 'X509_STORE_get_ex_new_index' macro redefined [-Wmacro-redefined]
#  define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \
          ^
/usr/local/include/openssl/x509_vfy.h:320:9: note: previous definition is here
#define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \
        ^
openssl_missing.c:65:36: error: invalid application of 'sizeof' to an incomplete type 'HMAC_CTX' (aka 'struct hmac_ctx_st')
    HMAC_CTX *ctx = OPENSSL_malloc(sizeof(HMAC_CTX));
                                   ^     ~~~~~~~~~~
/usr/local/include/openssl/crypto.h:126:23: note: expanded from macro 'OPENSSL_malloc'
        CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
                      ^~~
/usr/local/include/openssl/ossl_typ.h:102:16: note: forward declaration of 'struct hmac_ctx_st'
typedef struct hmac_ctx_st HMAC_CTX;
               ^
openssl_missing.c:68:5: warning: implicit declaration of function 'HMAC_CTX_init' is invalid in C99 [-Wimplicit-function-declaration]
    HMAC_CTX_init(ctx);
    ^
openssl_missing.c:78:2: warning: implicit declaration of function 'HMAC_CTX_cleanup' is invalid in C99 [-Wimplicit-function-declaration]
        HMAC_CTX_cleanup(ctx);
        ^
openssl_missing.c:90:13: error: incomplete definition of type 'struct X509_crl_st'
        *psig = crl->signature;
                ~~~^
/usr/local/include/openssl/ossl_typ.h:121:16: note: forward declaration of 'struct X509_crl_st'
typedef struct X509_crl_st X509_CRL;
               ^
openssl_missing.c:92:13: error: incomplete definition of type 'struct X509_crl_st'
        *palg = crl->sig_alg;
                ~~~^
/usr/local/include/openssl/ossl_typ.h:121:16: note: forward declaration of 'struct X509_crl_st'
typedef struct X509_crl_st X509_CRL;
               ^
openssl_missing.c:102:13: error: incomplete definition of type 'struct X509_req_st'
        *psig = req->signature;
                ~~~^
/usr/local/include/openssl/x509.h:91:16: note: forward declaration of 'struct X509_req_st'
typedef struct X509_req_st X509_REQ;
               ^
openssl_missing.c:104:13: error: incomplete definition of type 'struct X509_req_st'
        *palg = req->sig_alg;
                ~~~^
/usr/local/include/openssl/x509.h:91:16: note: forward declaration of 'struct X509_req_st'
typedef struct X509_req_st X509_REQ;
               ^

I tried everything in this thread, but to no avail.

The fix was to uninstall rbenv and install rvm instead: compilation of Ruby proceeded without a hitch thereafter.

... the irony being that I switched from rvm to rbenv a couple years ago because rvm had an intractable issue with openssl at the time.

I guess I should be thankful that it's never been the case that both of them have an issue with openssl at the same time.

I had the same issue and here is how I fixed it (thanks to a lot a googling)

$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

then follow the installation until the end (next, next, next,...)
and then install like you usually do:

$ rbenv install 2.5.5

@thegreyfellow this seeeeeems to be working? 馃 I'm not getting errors about "cross compiling C programs" and "--host" flags anymore, but my fans are going crazy and it's stalled at Installing ruby-2.3.8... ruby-build: use readline from homebrew for aaaages 馃槩

Update: OMG it worked! Took _for EVER_ to run, though...
Thank you so much! 鉂わ笍

@cglotr Your comment helped me get things running smoothly for me. Many thanks!

Its almost 2020 and still I got this error. This is how I solved it

First run

$ brew uninstall openssl
$ brew --prefix openssl
$ sudo mv /usr/local/include /usr/local/include_old
$ rm ~/.rbenv

Add path found with brew --prefix openssl to .zshrc

export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

Open new terminal or source RC file

$ rbenv install 2.5.1
$ rbenv global 2.5.1
$ ruby --version

I had this problem in 2020 @trackq but your comment saved me. The only last thing I would add is: don't forget to add it to your .bash_profile:

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Was this page helpful?
0 / 5 - 0 ratings