无法使用 rbenv 和 ruby-build 构建 Ruby 2.5.0

Failing to build Ruby 2.5.0 with rbenv and ruby-build

所以我正在尝试使用 rbenv 安装 ruby 2.5.0,这是我的问题:

$ rbenv install 2.5.0
ruby-build: use openssl from homebrew
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...
ruby-build: use readline from homebrew

BUILD FAILED (OS X 10.13.3 using ruby-build 20171226-3-g01e7b7b)

Inspect or clean up the working tree at /var/folders/6d/p9mv033d1xv9hc4xbdr7fxf40000gp/T/ruby-build.20180212121818.63339
Results logged to /var/folders/6d/p9mv033d1xv9hc4xbdr7fxf40000gp/T/ruby-build.20180212121818.63339.log

Last 10 log lines:
installing capi-docs:
/Users/lukeholloway/.rbenv/versions/2.5.0/share/doc/ruby
The Ruby OpenSSL extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
  --prefix=/Users/lukeholloway/.rbenv/versions/2.5.0
  --with-openssl-dir=/usr/local/opt/openssl
  --with-readline-dir=/usr/local/opt/readline
  CC=clang
  LDFLAGS=-L/Users/lukeholloway/.rbenv/versions/2.5.0/lib 
  CPPFLAGS=-I/Users/lukeholloway/.rbenv/versions/2.5.0/include 

问题似乎与 mac 版本的 OpenSSL 和 Homebrew 版本之间的路径有关。我在我的 mac 上使用 Homebrew 来处理一切,仅供参考。

这是我的 openssl 文件夹:

$ which openssl
/usr/local/opt/openssl/bin/openssl
$ openssl version
OpenSSL 1.0.2n  7 Dec 2017

我的 .bash_profile 中有这一行,以使其使用与 Homebrew 一起安装的较新版本:

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

它似乎正在加载正确的 OpenSSL 版本,但它仍然无法正确编译。它对 ruby.

的任何版本执行此操作

有谁知道具体是怎么回事吗?任何帮助都会很棒!

这个错误发生在我升级自制软件后。

我刚刚花了 2 天时间试图修复这个错误,基本上重新安装了所有东西。这就是我找到解决方案的方式(TL; TR 我很笨)

  1. 运行 brew doctor
  2. 它说"Your Xcode version is too old, you are using 9.0 and latest is 10.0"
  3. 我去了应用商店,打开更新选项卡,那里什么也没有
  4. 搜索 Xcode 并注意到版本 10 可用
  5. 安装后Xcode打开
  6. 运行 rbenv install 2.5.0 并工作。
  7. 恨我所有的存在