无法在macOS Sierra上使用rbenv和ruby-build构建Ruby 2.5.0

时间:2018-01-02 13:09:12

标签: ruby rbenv

我尝试在macOS Sierra上使用rbenv和ruby-build安装ruby 2.5.0,但它失败了,我收到如下错误消息:

$ 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

我检查了日志文件,发现以下错误:

  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)) {
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~  ^

我不知道为什么会发生这种错误。如果你能解释如何解决这个问题,我将不胜感激。

之后,我尝试使用Xcode在macOS High Sierra上提供的gcc rbenv install 2.5.0,同样的问题发生了。

3 个答案:

答案 0 :(得分:5)

它适用于我在同一个操作系统上。 An issue in ruby-build that produced this error was reported and fixed recently.

更新rbenv和ruby-build

  • 如果您从git获取它们:

    cd ~/.rbenv
    git pull
    cd plugins/ruby-build
    git pull
    
  • 如果你是从自制软件中获取它们的话:

    brew update
    brew upgrade rbenv ruby-build
    

再次尝试rbenv install 2.5.0

如果您正在使用rbenv& ruby-build homebrew,你可以尝试从git中使用它们。

答案 1 :(得分:0)

我终于解决了这个问题。当这个问题发生时,我的rbenv treid使用openssl-1.1.0g安装ruby 2.5.0。这个openssl是由rbenv和ruby-build选择的。 在我的环境中,我安装了MacPort的openssl@1.0.2n_0。我选择这个openssl来安装带有rbenv和ruby-build的ruby 2.5.0。

$ 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

当我没有使用--with-gdbm-dir=/opt/local时,我收到以下消息:

*** 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.

答案 2 :(得分:0)

使用它来安装带有rbenv的ruby最后版本

and similarly for Tag=2 this would be a group by method