Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failing to build Ruby 2.5.0 with rbenv and ruby-build on macOS Sierra

Tags:

ruby

rbenv

I tried to install ruby 2.5.0 with rbenv and ruby-build on macOS Sierra, but it failed and I got error messages as below:

$ rbenv install 2.5.0
Downloading openssl-1.1.0g.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/de4d501267da39310905cb6dc8c6121f7a2cad45a7707f76df828fe1b85073af
Installing openssl-1.1.0g...
Installed openssl-1.1.0g to /Users/hikaru/.rbenv/versions/2.5.0

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

BUILD FAILED (OS X 10.12.6 using ruby-build 20171226)

Inspect or clean up the working tree at 
/var/folders/5q/dy9blchn6fq1_673pm0ybt0h0000gn/T/ruby-
build.20180102205530.13528
Results logged to /var/folders/5q/dy9blchn6fq1_673pm0ybt0h0000gn/T/ruby-build.20180102205530.13528.log

Last 10 log lines:
make[1]: *** Waiting for unfinished jobs....
installing default ripper libraries
compiling ancdata.c
compiling raddrinfo.c
compiling ifaddr.c
installing default socket libraries
linking shared-object zlib.bundle
linking shared-object socket.bundle
linking shared-object ripper.bundle
make: *** [build-ext] Error 2

I checked the log files and found the error below:

  ossl_x509cert.c:334:59: error: member reference type 'int' is not a pointer
if (!i2a_ASN1_OBJECT(out, X509_get0_tbs_sigalg(x509)->algorithm)) {
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~  ^

I have no idea why this error happens. I would appreciate it if you would explain how to solve this problem.

After then, I tried to rbenv install 2.5.0 with gcc provided by Xcode on macOS High Sierra, and same problem happened.

like image 206
montblanc18 Avatar asked Jan 28 '23 22:01

montblanc18


2 Answers

It works for me on the same OS. An issue in ruby-build that produced this error was reported and fixed recently.

Update rbenv and ruby-build

  • If you're getting them from git:

    cd ~/.rbenv
    git pull
    cd plugins/ruby-build
    git pull
    
  • If you're getting them from homebrew:

    brew update
    brew upgrade rbenv ruby-build
    

and try rbenv install 2.5.0 again.

If you're using rbenv & ruby-build homebrew, you could try using them from git.

like image 191
Dave Schweisguth Avatar answered Apr 29 '23 21:04

Dave Schweisguth


I finally fixed this problem. When this problem happened, my rbenv treid to install ruby 2.5.0 using openssl-1.1.0g. This openssl was selected by rbenv and ruby-build. In my environment, I installed [email protected]_0 by MacPort. I selected this openssl to installing ruby 2.5.0 with rbenv and ruby-build.

$ rbenv versions
  system
* 2.4.0 
$ port installed | grep openssl
  openssl @1.0.2n_0 (active)
$ RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/local --with-gdbm-dir=/opt/local"  rbenv install -v 2.5.0
$ rbenv versions
  system
* 2.4.0 
  2.5.0

When I did not use --with-gdbm-dir=/opt/local, I got the below message:

*** Following extensions are not compiled:
gdbm:
    Could not be configured. It will not be installed.
    Check ext/gdbm/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want.
like image 26
montblanc18 Avatar answered Apr 29 '23 23:04

montblanc18