1

低于 2.3.1 的 Ruby 版本在clang --version12 或更高版本时无法安装。要重现该问题,首先通过软件更新获取 xcode 命令行开发人员工具版本 12 或擦除您的 Mac 并安装自制软件:

# homebrew installs version 12 of the command line developer tools as well
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

然后这失败了:

brew install rbenv
rbenv install 2.2.5

rbenv install 2.2.5 的输出:

Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/kburnett/.rbenv/versions/2.2.5

Downloading ruby-2.2.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.5.tar.bz2
Installing ruby-2.2.5...

WARNING: ruby-2.2.5 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

ruby-build: using readline from homebrew

BUILD FAILED (Mac OS X 10.15.6 using ruby-build 20200819)

Inspect or clean up the working tree at /var/folders/my/qwq5ncb54svfh_qs70kjh4qc0000gn/T/ruby-build.20200921102602.41313.Eghhn7
Results logged to /var/folders/my/qwq5ncb54svfh_qs70kjh4qc0000gn/T/ruby-build.20200921102602.41313.log

Last 10 log lines:
compiling ../.././ext/psych/yaml/reader.c
compiling ../.././ext/psych/yaml/emitter.c
linking shared-object json/ext/generator.bundle
compiling ../.././ext/psych/yaml/parser.c
installing default psych libraries
linking shared-object bigdecimal.bundle
linking shared-object psych.bundle
linking shared-object nkf.bundle
linking shared-object date_core.bundle
make: *** [build-ext] Error 2

在显示“结果记录到”的文件中,它报告有 3 个警告和 4 个错误。错误是这些:

 % grep "error:" /var/folders/my/qwq5ncb54svfh_qs70kjh4qc0000gn/T/ruby-build.20200921102602.41313.log
./openssl_missing.h:71:6: error: conflicting types for 'HMAC_CTX_copy'
./openssl_missing.h:95:5: error: conflicting types for 'EVP_CIPHER_CTX_copy'
./openssl_missing.h:173:5: error: conflicting types for 'BN_rand_range'
./openssl_missing.h:177:5: error: conflicting types for 'BN_pseudo_rand_range'

https://gist.github.com/burnettk/04fb637c4ec18f621b2df500dbcec00e上的问题要点。

4

2 回答 2

3

Burnettk 将 Xcode CommandLineTools 更改为低于 12 的版本是正确的,但是没有必要 delete /Library/Developer/CommandLineTools,如果您每天使用 Xcode,这很可能会导致您的环境中出现其他问题。

首先,打开 Xcode 并转到,然后检查下拉菜单Preferences > Locations中有哪些选项。Command Line Tools如果可用,请选择Xcode 11.x并重试安装。 选择了 Xcode 11.7 命令行工具的位置视图

如果您还没有该版本,请从https://developer.apple.com/downloads/安装低于 12.0 的“命令行工具”的最高版本。完成后,返回位置首选项,选择刚刚安装的工具,然后重新安装 Ruby。

于 2020-11-09T13:38:33.207 回答
2

这与 Xcode 12 版本(2020 年 9 月 16 日)中断了。要“修复”/解决该问题,如果您已经clang --version报告了版本 12 点的内容,您可以sudo rm -rf /Library/Developer/CommandLineTools然后转到https://developer.apple.com/downloads/,使用您的 Apple ID 登录,然后找到“命令适用于 Xcode 11.5" 或类似版本的 Line Tools。一旦clang --version报告 11 点的东西,这应该再次起作用:rbenv install 2.2.5

此解决方法最初是由 bfreezy 在https://github.com/rbenv/ruby-build/issues/1353发现的。

于 2020-09-23T13:59:19.607 回答