与使用捆绑器的山狮nokogiri宝石的麻烦

时间:2013-08-28 04:03:18

标签: ruby gem bundler nokogiri

我可以 SUCCESSFULLY 使用

安装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

然而,当我运行“bundle install”时,我遇到了libxml2问题。我的问题是:如何通过bundler安装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.

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

谢谢!

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分: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

if you dont trust https pipe to shell, here's the script raw url[gist url]

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

临时解决方案1 ​​

这需要几分钟,安装后会吃掉100 MiB +。

gem install nokogiri

无论哪种方式,libxml2都需要变得更加稳定,或者它是一个事实上的分叉,并且更适合每个人。

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