You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法安装Ruby 2.7.6:rbenv构建失败问题求助

Ruby 2.7.6 安装失败问题

问题描述

尝试安装Ruby 2.7.6,执行rbenv version时提示:

rbenv: version `2.7.6' is not installed (set by /Users/[USER]/Documents/[FOLDER]/.ruby-version)

已创建内容为2.7.6的.ruby-version文件,但执行rbenv install时失败,错误提示:

BUILD FAILED (macOS 12.5 using ruby-build 20220726)

环境信息

  • 当前已安装Ruby版本:2.6.10
  • 运行环境:MacBook Pro(macOS v12.5)

终端执行日志

(base) uxdw@MacBook-Pro [FOLDER] % rbenv install      
Downloading openssl-1.1.1q.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca
Installing openssl-1.1.1q...
patching file test/v3ext.c
Installed openssl-1.1.1q to /Users/[USER]/.rbenv/versions/2.7.6

Downloading ruby-2.7.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.bz2
Installing ruby-2.7.6...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 12.5 using ruby-build 20220726)

Inspect or clean up the working tree at /var/folders/sz/svbmflb15kd5dy8g9kctn9t40000gn/T/ruby-build.20220805134427.72844.lmy9oj
Results logged to /var/folders/sz/svbmflb15kd5dy8g9kctn9t40000gn/T/ruby-build.20220805134427.72844.log

Last 10 log lines:
compiling date_parse.c
linking shared-object strscan.bundle
compiling date_strftime.c
compiling date_strptime.c
linking shared-object io/console.bundle
installing default date_core libraries
linking shared-object objspace.bundle
linking shared-object nkf.bundle
linking shared-object date_core.bundle
make: *** [build-ext] Error 2
(base) uxdw@MacBook-Pro [FOLDER] % 

解决方法

1. 更新ruby-build

旧版本ruby-build可能存在系统兼容性问题,先更新:

brew update && brew upgrade ruby-build

2. 指定OpenSSL路径编译

手动指定刚安装的OpenSSL路径,避免系统自带版本冲突:

RUBY_CONFIGURE_OPTS="--with-openssl-dir=/Users/[USER]/.rbenv/versions/2.7.6/openssl-1.1.1q" rbenv install 2.7.6

3. 补全编译依赖

确保安装所有编译Ruby所需的依赖包:

brew install openssl readline libyaml gdbm

4. 清理临时编译文件

删除之前的编译临时目录,重新执行安装:

rm -rf /var/folders/sz/svbmflb15kd5dy8g9kctn9t40000gn/T/ruby-build.20220805134427.72844.lmy9oj
rbenv install 2.7.6

5. 退出conda环境后安装

当前终端处于conda的base环境,可能干扰编译,先退出再尝试:

conda deactivate
rbenv install 2.7.6

内容的提问来源于stack exchange,提问作者Rich

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 10:15:35