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

Mac M1环境下安装nokogumbo 2.0.5失败,求解决方案

解决nokogumbo 2.0.5安装失败(arm64架构符号未找到)的问题

问题描述

尝试使用gem install nokogumbo或bundle install安装nokogumbo 2.0.5时,出现以下错误:

Installing nokogumbo 2.0.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/rafaelpolonio/.rvm/gems/ruby-2.7.6/gems/nokogumbo-2.0.5/ext/nokogumbo
/Users/rafaelpolonio/.rvm/rubies/ruby-2.7.6/bin/ruby -I
/Users/rafaelpolonio/.rvm/rubies/ruby-2.7.6/lib/ruby/site_ruby/2.7.0 extconf.rb
checking for whether
-I/Users/rafaelpolonio/.rvm/rubies/ruby-2.7.6/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.9-arm64-darwin/ext/nokogiri
is accepted as CFLAGS... yes
checking for whether
-I/Users/rafaelpolonio/.rvm/rubies/ruby-2.7.6/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.9-arm64-darwin/ext/nokogiri/include
is accepted as CFLAGS... yes
checking for whether
1 warning generated.
compiling ./../../gumbo-parser/src/tag.c
compiling ./../../gumbo-parser/src/parser.c
./../../gumbo-parser/src/parser.c:540:10: warning: cast to smaller integer type
'GumboInsertionMode' from 'void *' [-Wvoid-pointer-to-enum-cast]
return (GumboInsertionMode) modes->data[(modes->length - 1)];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
linking shared-object nokogumbo/nokogumbo.bundle
Undefined symbols for architecture arm64:
"_Nokogiri_wrap_xml_document", referenced from:
_parse_continue in nokogumbo.o
"_cNokogiriXmlSyntaxError", referenced from:
_add_errors in nokogumbo.o
"_htmlNewDocNoDtD", referenced from:
_parse_continue in nokogumbo.o
"_mNokogiri", referenced from:
_Init_nokogumbo in nokogumbo.o
"_xmlAddChild", referenced from:
_build_tree in nokogumbo.o
"_xmlCreateIntSubset", referenced from:
_parse_continue in nokogumbo.o
"_xmlFreeDoc", referenced from:
_parse_cleanup in nokogumbo.o
"_xmlNewCDataBlock", referenced from:
_build_tree in nokogumbo.o
"_xmlNewDocComment", referenced from:
_build_tree in nokogumbo.o
"_xmlNewDocNode", referenced from:
_build_tree in nokogumbo.o
"_xmlNewDocText", referenced from:
_build_tree in nokogumbo.o
"_xmlNewNs", referenced from:
_build_tree in nokogumbo.o
"_xmlNewNsProp", referenced from:
_build_tree in nokogumbo.o
"_xmlSearchNs", referenced from:
_build_tree in nokogumbo.o
"_xmlSetNs", referenced from:
_build_tree in nokogumbo.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nokogumbo.bundle] Error 1

已尝试升级nokogiri至1.13.9,但问题仍未解决。

解决方案

  • 指定nokogiri编译参数安装nokogumbo
    用bundle配置指定nokogiri的库和头文件路径,再执行安装:

    bundle config build.nokogumbo --with-nokogiri-lib=$(bundle show nokogiri)/lib --with-nokogiri-include=$(bundle show nokogiri)/include
    bundle install
    

    如果直接用gem安装:

    gem install nokogumbo -v 2.0.5 -- --with-nokogiri-lib=$(gem which nokogiri | sed 's/lib\/ruby.*//')lib --with-nokogiri-include=$(gem which nokogiri | sed 's/lib\/ruby.*//')include
    
  • 尝试Rosetta终端运行
    针对M1/M2等arm64芯片,右键终端图标选择「使用Rosetta打开」,在新终端里重新执行bundle install或gem install nokogumbo -v 2.0.5。

  • 调整nokogiri版本适配
    nokogumbo 2.0.5可能与nokogiri 1.13.x存在兼容性问题,尝试降级nokogiri到稳定版本:
    在Gemfile中添加:

    gem 'nokogiri', '~> 1.11.7'
    

    然后执行:

    bundle update nokogiri
    bundle install
    
  • 清理缓存重新安装
    清除本地相关gem缓存,重新拉取依赖:

    gem cleanup nokogumbo nokogiri
    rm -rf Gemfile.lock vendor/bundle
    bundle install
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 03:55:20