MacOS M1 Sonoma 14.6.1下各类Ruby版本管理器均无法安装Ruby求助
Ruby版本管理工具安装Ruby失败问题排查
我尝试过RVM、Rbenv、ASDF以及ruby-install等各类Ruby版本管理工具安装Ruby,但始终遇到相同错误。背景说明:我需要为React Native项目安装Ruby,当前项目因gem文件冲突无法执行bundle install,想测试不同Ruby版本,且怀疑当前使用的是系统Ruby,因此尝试使用版本管理器。
错误日志
ruby-install 2.7.5 >>> Installing ruby 2.7.5 into /Users/my-user/.rubies/ruby-2.7.5 ... >>> Installing dependencies for ruby 2.7.5 ... Warning: automake 1.17 is already installed and up-to-date. To reinstall 1.17, run: brew reinstall automake Warning: bison 3.8.2 is already installed and up-to-date. To reinstall 3.8.2, run: brew reinstall bison Warning: readline 8.2.13 is already installed and up-to-date. To reinstall 8.2.13, run: brew reinstall readline Warning: libyaml 0.2.5 is already installed and up-to-date. To reinstall 0.2.5, run: brew reinstall libyaml Warning: gdbm 1.24 is already installed and up-to-date. To reinstall 1.24, run: brew reinstall gdbm Warning: libffi 3.4.6 is already installed and up-to-date. To reinstall 3.4.6, run: brew reinstall libffi Warning: openssl@1.1 1.1.1w is already installed and up-to-date. To reinstall 1.1.1w, run: brew reinstall openssl@1.1 >>> Downloading https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.5.tar.xz into /Users/my-user/src ... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 11.5M 100 11.5M 0 0 5299k 0 0:00:02 0:00:02 --:--:-- 5301k >>> Verifying ruby-2.7.5.tar.xz ... >>> Extracting ruby-2.7.5.tar.xz to /Users/my-user/src/ruby-2.7.5 ... >>> Configuring ruby 2.7.5 ... checking for ruby... /usr/bin/ruby tool/config.guess already exists tool/config.sub already exists checking build system type... aarch64-apple-darwin23.6.0 checking host system type... aarch64-apple-darwin23.6.0 checking target system type... aarch64-apple-darwin23.6.0 checking for gcc... gcc .... .... checking whether dtrace USDT is available... yes(-xnolibs) checking whether dtrace needs post processing... no checking for __builtin_setjmp... (cached) no checking for _setjmpex as a macro or function... no checking for _setjmp as a macro or function... yes checking for sigsetjmp as a macro or function... yes checking for setjmp type... sigsetjmp,0 checking for prefix of external symbols... _ checking pthread.h usability... yes checking pthread.h presence... yes checking for pthread.h... yes checking if make is GNU make... make ℹ info Invoking all target node:internal/process/promises:246 triggerUncaughtException(err, true /* fromPromise */); ^ [UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] { code: 'ERR_UNHANDLED_REJECTION' } no checking for safe null command for make... configure: error: no candidate for safe null command !!! Configuration of ruby 2.7.5 failed! my-user@Danis-MacBook-Pro-6 ~ %
当前$PATH变量内容
/Users/my-user/.nvm/versions/node/v16.13.1/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/my-user/.cargo/bin:/Users/my-user/.rvm/bin
调试与解决建议
- 排查
make命令异常:错误日志中出现Node的未处理Promise报错,说明你的make命令可能被Node脚本替换,而非系统自带的GNU make。先执行which make查看路径,正常应为/usr/bin/make;若路径异常,调整PATH优先级,临时执行export PATH="/usr/bin:$PATH"后再尝试安装。 - 使用干净环境测试:临时进入无额外配置的shell,避免环境变量干扰,执行
env -i HOME=$HOME PATH=/usr/bin:/bin:/opt/homebrew/bin:/opt/homebrew/sbin bash,再尝试用ruby-install安装Ruby。 - 指定编译参数适配Apple Silicon:针对aarch64架构,安装Ruby 2.7.x时需指定openssl路径,执行:
ruby-install ruby 2.7.5 -- --with-openssl-dir=$(brew --prefix openssl@1.1) - 修复依赖完整性:重新安装所有编译依赖,确保无损坏:
brew reinstall automake bison readline libyaml gdbm libffi openssl@1.1 - 排除Node环境干扰:错误中的Node报错表明安装过程中意外触发了Node进程,可能是shell配置文件(如.zshrc/.bashrc)中的Node脚本导致,临时注释相关配置后再尝试安装。
内容的提问来源于stack exchange,提问作者Dani Tseitlin
相关产品推荐
相关产品推荐

