我一直试图在Mac OS 10.9.3上安装Nokogiri,无论我如何尝试,最终安装都会失败,并显示以下错误消息:$ sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/libBuilding native extensions with: '--with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib'This could take a while...Building nokogiri using packaged libraries.ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/libBuilding nokogiri using packaged libraries.checking for iconv.h... yeschecking for iconv_open() in iconv.h... nochecking for iconv_open() in -liconv... nochecking for libiconv_open() in iconv.h... nochecking for libiconv_open() in -liconv... no-----libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.-----Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.2.1 for inspection.Results logged to /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.2.1/ext/nokogiri/gem_make.out遵循了很多在网上找到的帮助,包括使用brew来构建和安装libxml2和libxslt以及从源代码构建libiconv之后(如“ 安装Nokogiri ”中所述),错误仍然存在。尝试为Nokogiri运行安装时,似乎可以找到libxml2和libxslt,但不能找到libiconv。任何对这些事情有更好了解的人都知道如何安装Nokogiri?
3 回答

Qyouu
TA贡献1786条经验 获得超11个赞
我遇到过同样的问题。不幸的是,“ 安装Nokogiri ”没有涵盖Iconv问题。这是我解决问题的方法。
首先安装homebrew,它将使您的生活更轻松。如果您已经安装了它,请确保通过如下更新来获取最新的公式:
brew update
注意:在OSX 10.9+中,您可能需要安装xCode命令工具以允许您安装libiconv。
xcode-select --install
然后安装更高版本的libiconv
brew install libiconv
然后安装你的宝石
gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14
- 3 回答
- 0 关注
- 809 浏览
添加回答
举报
0/150
提交
取消