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

MacOS Ventura更新后bundle install安装racc 1.6.1失败求助

问题:MacOS Ventura更新后bundle install失败(racc gem安装报错)

环境信息

HW: Mac Intel silicon
OS: MacOS Ventura - Version 13.1
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin21]
rails 7.0.2.2

问题描述

安装MacOS Ventura更新后,执行bundle install时失败,报错指向racc gem的原生扩展构建环节。

已尝试操作

  • 执行xcode-select --install安装Xcode命令行工具
  • 在系统设置中确认终端已获得开发者工具访问权限

错误日志

Installing racc 1.6.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /Users/my-mac/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/racc-1.6.1/ext/racc/cparse
/Users/my-mac/.asdf/installs/ruby/3.1.0/bin/ruby -I /Users/my-mac/.asdf/installs/ruby/3.1.0/lib/ruby/3.1.0 -r ./siteconf20230126-46139-whcmb7.rb extconf.rb
checking for rb_block_call()... yes
checking for rb_ary_subseq()... yes
creating Makefile

current directory: /Users/my-mac/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/racc-1.6.1/ext/racc/cparse
make DESTDIR\= clean

current directory: /Users/my-mac/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/racc-1.6.1/ext/racc/cparse
make DESTDIR\=
compiling cparse.c
linking shared-object racc/cparse.bundle
ld: warning: -undefined dynamic_lookup may not work with chained fixups

current directory: /Users/my-mac/.asdf/installs/ruby/3.1.0/lib/ruby/gems/3.1.0/gems/racc-1.6.1/ext/racc/cparse
make DESTDIR\= install
make: /usr/local/bin/gmkdir: No such file or directory
make: *** [.sitearchdir.-.racc.time] Error 1

make install failed, exit code 2

....

An error occurred while installing racc (1.6.1), and Bundler cannot continue.

In Gemfile:
  rails was resolved to 7.0.2.2, which depends on
    actioncable was resolved to 7.0.2.2, which depends on
      actionpack was resolved to 7.0.2.2, which depends on
        actionview was resolved to 7.0.2.2, which depends on
          rails-dom-testing was resolved to 2.0.3, which depends on
            nokogiri was resolved to 1.13.10, which depends on
              racc

排查发现

系统中不存在以下路径:

/usr/local/bin/gmkdir
/opt/local/bin/gmkdir

解决思路

  1. 安装GNU coreutils:gmkdir是GNU版本的mkdir,属于coreutils工具包。通过Homebrew安装:

    brew install coreutils
    

    安装完成后,GNU工具会默认以g前缀命名存放在/usr/local/bin下,此时gmkdir会自动生成。

  2. 确认PATH环境变量配置:检查/usr/local/bin是否在PATH中,执行:

    echo $PATH
    

    如果未包含,将其添加到shell配置文件(如~/.zshrc或~/.bash_profile):

    echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
    
  3. 重新安装racc gem:先卸载失败的安装残留,再重新执行bundle install:

    gem uninstall racc
    bundle install
    
  4. 更新Ruby版本(可选):当前Ruby 3.1.0可能与MacOS Ventura存在兼容性问题,尝试更新到同系列较新版本或3.2.x版本(通过asdf):

    asdf install ruby 3.1.4
    asdf global ruby 3.1.4
    bundle install
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 17:20:35