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

在macOS M2上用rbenv安装Ruby 3.2.2:缺失psych和libyaml问题

解决M2 Mac上rbenv安装Ruby 3.2.2时的yaml扩展缺失问题

出现的错误信息:

yaml.rb:3: warning: It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
The Ruby yaml extension was not compiled.
ERROR: Ruby install aborted due to missing extensions

解决步骤:

  • 安装libyaml依赖(需提前安装Homebrew):
    brew install libyaml
    
  • 设置环境变量,让rbenv编译Ruby时能找到libyaml:
    export RUBY_CONFIGURE_OPTS="--with-libyaml-dir=$(brew --prefix libyaml)"
    
  • 重新执行Ruby安装命令:
    rbenv install 3.2.2
    
  • 若需永久生效该环境变量,将配置写入shell配置文件(以zsh为例):
    echo 'export RUBY_CONFIGURE_OPTS="--with-libyaml-dir=$(brew --prefix libyaml)"' >> ~/.zshrc
    source ~/.zshrc
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 14:12:02