Nokogiri为什么不安装?

R V*_*R V 4 ruby nokogiri

我在安装Nokogiri时遇到了麻烦.当我运行bundle installgem install nokogiri安装失败.

我得到的错误是:(注意:此失败来自使用nokogiri.org上的安装命令)

Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/roneesh/.rbenv/versions/1.9.3-p194/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
Extracting libxml2-2.8.0.tar.gz into tmp//ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp//ports/libxml2/2.8.0/configure.log' to see what happened.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用的命令是:

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
Run Code Online (Sandbox Code Playgroud)

我已经用brew安装了xml2,xslt和libiconv,并在上面输入了正确的版本.仍然没有决议.我没有做的唯一事情是来自源码的libiconv(我的wget命令由于某种原因不起作用).

Osc*_*ett 5

您需要指定nokogiri来代替使用系统库,因此它不会尝试自己构建它们.

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install

在这里找到答案:在mac(libxml2)上安装nokogiri 1.6.0时出错.