我正在尝试在OS X Leopard(10.5.8)中的RVM托管Ruby 1.8.7安装下安装Nokogiri gem。
我收到以下错误:
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/user/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... no
-----
The function 'xmlHasFeature' is missing from your installation of libxml2. Likely this means that your installed version of libxml2 is old enough that nokogiri will not work well. To get around this problem, please upgrade your installation of libxml2.
Please visit http://nokogiri.org/tutorials/installing_nokogiri.html for more help!
*** extconf.rb failed ***
我通过自制软件安装了最新的libxml2(brew install libxml2),所以我不知道还有什么可以尝试。
我尝试了Nokogiri网站上的说明,我无法通过Nokogiri gem安装来识别libxml2。
每the instructions 我通过homebrew安装并链接了libxml2和libxslt:
brew install libxml2 libxslt
brew link libxml2 libxslt
gem install nokogiri
错误消息已更改,但Nokogiri安装程序抱怨缺少libxml2:
...
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies
安装的libxml2版本是2.7.8。
我尝试从homebrew安装iconv库,看看我是否可以解决错误checking for iconv_open() in iconv.h... no
,所以我运行了命令:
brew install libiconv
brew link libiconv
在完成安装后,我尝试再次安装nokogiri gem,以获取此错误消息,安装程序现在抱怨 libiconv缺失
hecking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
我很无能。
答案 0 :(得分:4)
根据您需要使用的http://nokogiri.org/tutorials/installing_nokogiri.html指示:
brew install libxml2 libxslt
brew link libxml2 libxslt
然后
gem install nokogiri
您使用的是brew install libxml2
吗?
答案 1 :(得分:0)
确保没有Nokogiri版本:
use gem uninstall nokogiri
首先安装Xcode的命令行工具。请参阅“How to use/install gcc on Mac OS X 10.8 / Xcode 4.4”。
然后运行以下命令:
brew install libxml2
gem install nokogiri
现在效果很好,我试过了。
答案 2 :(得分:-1)
brew install libxml2 libxslt
gem install nokogiri -- \
--with-xml2-lib=/usr/local/Cellar/libxml2/2.7.x/lib \
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.xx \
--with-iconv-lib=/usr/lib \
--with-iconv-include=/usr/local/include