为什么在Mac OS上安装Nokogiri失败并缺少libiconv?

我一直试图在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/lib

Building 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/lib

Building nokogiri using packaged libraries.

checking for iconv.h... yes

checking for iconv_open() in iconv.h... no

checking for iconv_open() in -liconv... no

checking for libiconv_open() in iconv.h... no

checking 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?


慕无忌1623718
浏览 752回答 3
3回答

Qyouu

我遇到过同样的问题。不幸的是,“ 安装Nokogiri ”没有涵盖Iconv问题。这是我解决问题的方法。首先安装homebrew,它将使您的生活更轻松。如果您已经安装了它,请确保通过如下更新来获取最新的公式:brew update注意:在OSX 10.9+中,您可能需要安装xCode命令工具以允许您安装libiconv。xcode-select --install然后安装更高版本的libiconvbrew install libiconv然后安装你的宝石gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Ruby