0

我可以使用成功安装 nokigiri

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

但是,当我运行“捆绑安装”时,我遇到了 libxml2 问题。我的问题是:如何让 nokogiri 通过捆绑器安装?

这是我的“捆绑安装”输出:

Installing nokogiri (1.6.0) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/philswenson/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2
Extracting libxml2-2.8.0.tar.gz into tmp/i686-apple-darwin11/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... OK
Running 'install' for libxml2 2.8.0... OK
Activating libxml2 2.8.0 (from /Users/philswenson/.rvm/gems/ruby-1.9.3-p448@3rdrevolution/gems/nokogiri-1.6.0/ports/i686-apple-darwin11/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/i686-apple-darwin11/ports/libxslt/1.1.26... OK
Running 'configure' for libxslt 1.1.26... OK
Running 'compile' for libxslt 1.1.26... OK
Running 'install' for libxslt 1.1.26... OK
Activating libxslt 1.1.26 (from /Users/philswenson/.rvm/gems/ruby-1.9.3-p448@3rdrevolution/gems/nokogiri-1.6.0/ports/i686-apple-darwin11/libxslt/1.1.26)...
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... yes
checking for xmlParseDoc() in -lxml2... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/philswenson/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --with-iconv-dir
    --without-iconv-dir
    --with-iconv-include
    --without-iconv-include=${iconv-dir}/include
    --with-iconv-lib
    --without-iconv-lib=${iconv-dir}/lib
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-xslt-dir
    --without-xslt-dir
    --with-xslt-include
    --without-xslt-include=${xslt-dir}/include
    --with-xslt-lib
    --without-xslt-lib=${xslt-dir}/lib
    --with-libxslt-config
    --without-libxslt-config
    --with-pkg-config
    --without-pkg-config
    --with-libxml-2.0-config
    --without-libxml-2.0-config
    --with-libiconv-config
    --without-libiconv-config
    --with-xml2lib
    --without-xml2lib


Gem files will remain installed in /Users/philswenson/.rvm/gems/ruby-1.9.3-p448@3rdrevolution/gems/nokogiri-1.6.0 for inspection.
Results logged to /Users/philswenson/.rvm/gems/ruby-1.9.3-p448@3rdrevolution/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out

An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.

有人能指出我正确的方向吗?

谢谢!

4

2 回答 2

1

sudo如果您使用的是 RVM 或类似的 Ruby 版本管理器,则不应使用。

于 2013-08-28T05:31:31.650 回答
0

这适用于最新的 Xcode CLT、山狮和小牛,以及 nokogiri 1.6.1

临时解决方案 0

正是 nokogiri 的补丁作为 brew 公式 libxslt 和 libxml2

curl -L https://gist.githubusercontent.com/steakknife/8969368/raw/install_nokogiri_brew_osx.sh | bash

如果您不信任 https 管道到 shell,这里是脚本原始 url[要点网址]

速度更快,并提供了一个已知好的、仅桶的 libiconv 和 nokogiri 的 libxml2 和 libxslt 副本。系统 libxml2 没有被触及。

临时解决方案 1

这需要几分钟,安装后会消耗 100 MiB+。

gem install nokogiri

无论哪种方式,libxml2 都需要变得更加稳定,或者它实际上是一个分支,并且为每个人提供了更多的工作。

不要打扰链接 libxml2 或 libxslt,sudo 任何东西,或者 make install libiconv,这些都是不必要且脆弱的。

于 2014-02-13T03:08:11.630 回答