Ruby 安装由于缺少扩展而中止:openssl、readline、zlib 编译错误 [英] Ruby install aborted due to missing extensions: openssl, readline, zlib compilation error

查看:112
本文介绍了Ruby 安装由于缺少扩展而中止:openssl、readline、zlib 编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 macOS Catalina.我正在尝试通过 rbenv 安装旧版本的 Ruby(1.9.3、2.1.2).但是,在尝试安装旧版本时,我不断收到以下错误.*安装 2.4 或更高版本时没问题.

I'm using macOs Catalina. I'm trying to install older version of Ruby (1.9.3, 2.1.2) via rbenv. However, I keep getting the errors below, when trying installing older version. *It was fine when installing 2.4 or newer.

我已经试过了

brew install openssl
brew install readline
brew install zlib

以及 brew 更新.我已经安装并更新了所有内容,但以下错误仍然不断出现.

as well as brew update. I have everything installed and up-to-dated but still the errors below keeps coming up.

我也试过用配置选项安装

I also did tried to install with configure option

RUBY_CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline` --with-openssl-dir=`brew --prefix openssl`" rbenv install 2.1.2

请告诉我如何解决这个问题.

Please let me know how I can fix this.

ruby-build:使用 homebrew 的 readline

ruby-build: using readline from homebrew

构建失败(Mac OS X 10.15.7 使用 ruby​​-build 20201005)

BUILD FAILED (Mac OS X 10.15.7 using ruby-build 20201005)

在以下位置检查或清理工作树/var/folders/80/ts3rxpm5199g71p1vm4xzydj03b4g3/T/ruby-build.20201113153529.74484.A9uFGC结果记录到/var/folders/80/ts3rxpm5199g71p1vm4xzydj03b4g3/T/ruby-build.20201113153529.74484.log

Inspect or clean up the working tree at /var/folders/80/ts3rxpm5199g71p1vm4xzydj03b4g3/T/ruby-build.20201113153529.74484.A9uFGC Results logged to /var/folders/80/ts3rxpm5199g71p1vm4xzydj03b4g3/T/ruby-build.20201113153529.74484.log

最后 10 行日志:未编译 Ruby openssl 扩展.未编译 Ruby readline 扩展.未编译 Ruby zlib 扩展.错误:Ruby 安装由于缺少扩展而中止配置使用的选项:
--prefix=/Users/username/.rbenv/versions/2.1.2
--with-openssl-dir=/usr/local/opt/openssl@1.0
--with-readline-dir=/usr/local/opt/readline
CC=clang
LDFLAGS=-L/Users/username/.rbenv/versions/2.1.2/lib
CPPFLAGS=-I/Users/username/.rbenv/versions/2.1.2/include

Last 10 log lines: The Ruby openssl extension was not compiled. The Ruby readline extension was not compiled. The Ruby zlib extension was not compiled. ERROR: Ruby install aborted due to missing extensions Configure options used:
--prefix=/Users/username/.rbenv/versions/2.1.2
--with-openssl-dir=/usr/local/opt/openssl@1.0
--with-readline-dir=/usr/local/opt/readline
CC=clang
LDFLAGS=-L/Users/username/.rbenv/versions/2.1.2/lib
CPPFLAGS=-I/Users/username/.rbenv/versions/2.1.2/include

推荐答案

  1. ruby-build 需要 clang 11 安装旧版 ruby​​:GitHub 评论链接
  1. ruby-build required clang 11 to install older version of ruby: GitHub comment link
  1. 如果 clang 已经更新到 12,你需要先核对它:sudo rm -rf/Library/Developer/CommandLineTools (源GitHub评论)
  2. 然后,从 官方 Apple Developers 网站(至少需要 免费的 Apple Developers帐户)
  1. If clang is already updated to 12, you need to nuke it first: sudo rm -rf /Library/Developer/CommandLineTools (source GitHub comment)
  2. Then, install Command_Line_Tools_for_Xcode_11.5.dmg for clang 11 from official Apple Developers's website (required at least Free Apple Developer Account)

  • 确保在安装旧版本的 ruby 时选择 openssl 1.0

    1. ruby-build 安装适当的 openssl例如.2.1.2 构建
    2. echo $RUBY_CONFIGURE_OPTS 以确保它为空或设置为使用 openssl@1.0
    3. 如果 ruby-build 仍然选择 openssl 1.1,那么你可以明确地 brew install rbenv/tap/openssl@1.0RUBY_CONFIGURE_OPTS=--with-openssl-dir=$(brew --prefix openssl@1.0)" (源 GitHub 评论)
    1. ruby-build installs appropriate openssl, eg. 2.1.2 build
    2. echo $RUBY_CONFIGURE_OPTS to ensure it's empty or set to use openssl@1.0
    3. If ruby-build still picks openssl 1.1, then you may explicitly brew install rbenv/tap/openssl@1.0 and RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" (source GitHub comment)

  • 这篇关于Ruby 安装由于缺少扩展而中止:openssl、readline、zlib 编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆