简体   繁体   English

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

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

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: 我尝试在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

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. 之后,我尝试在macOS High Sierra上使用Xcode提供的gcc rbenv install 2.5.0 ,并发生了相同的问题。

It works for me on the same OS. 它适用于同一操作系统。 An issue in ruby-build that produced this error was reported and fixed recently. 最近报告并修复了在ruby-build中产生此错误的问题。

Update rbenv and ruby-build 更新rbenv和ruby-build

  • If you're getting them from git: 如果要从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. 然后尝试rbenv install 2.5.0

If you're using rbenv & ruby-build homebrew, you could try using them from git. 如果您使用的是rbenv&ruby-build homebrew,则可以尝试从git中使用它们。

I finally fixed this problem. 我终于解决了这个问题。 When this problem happened, my rbenv treid to install ruby 2.5.0 using openssl-1.1.0g. 发生此问题时,我的rbenv treid使用openssl-1.1.0g安装ruby 2.5.0。 This openssl was selected by rbenv and ruby-build. 这是由rbenv和ruby-build选择的openssl。 In my environment, I installed openssl@1.0.2n_0 by MacPort. 在我的环境中,我通过MacPort安装了openssl@1.0.2n_0。 I selected this openssl to installing ruby 2.5.0 with rbenv and ruby-build. 我选择此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

When I did not use --with-gdbm-dir=/opt/local , I got the below message: 当我不使用--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.

用它来安装rbenv的ruby最新版本

RUBY_CONFIGURE_OPTS="--disable-dtrace" rbenv install 2.5.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM