Gem安装忽略nokogiri的标志

问题描述:

我正在尝试安装nokogiri 1.6.0版,并且有一些问题。Gem安装忽略nokogiri的标志

$ gem install nokogiri -v '1.6.0' -- --with-xml2-dir=/usr/local/Cellar/libxml2/2.9.1 --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 
Building native extensions with: '--with-xml2-dir=/usr/local/Cellar/libxml2/2.9.1 --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28' 
This could take a while... 
ERROR: Error installing nokogiri: 
    ERROR: Failed to build gem native extension. 

    /Users/shamatov/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb --with-xml2-dir=/usr/local/Cellar/libxml2/2.9.1 --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 
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/shamatov/.rvm/gems/ruby-1.9.3-p448/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/shamatov/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.0/ports/i686-apple-darwin11/libxslt/1.1.26)... 
checking for libxml/parser.h... *** 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. 

正如你所看到的,我用:--with-xml2-dir=/usr/local/Cellar/libxml2/2.9.1 --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 但extconf.rb使用libxml2-2.8.0.tar.gz 同为XSLT它使用的libxslt-1.1.26.tar.gz

如何解决这个问题,导致改变版本实际上不是一个选项? 感谢

尝试:

$ gem uninstall nokogiri # JIC 
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri \ 
    -- --use-system-libraries \ 
     --with-iconv-dir="$(brew --prefix libiconv)" \ 
     --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" \ 
     --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config" 

希望它能帮助。

+0

谢谢,太棒了。你能解释它是如何工作的吗?为什么我的版本不正确 – 2014-10-31 13:50:20

+2

我还没有记住在Mac上编译捆绑的lib [xml,xslt]库时出现了什么问题,但是在安装nokogiri时应该始终打开“NOKOGIRI_USE_SYSTEM_LIBRARIES = 1”标志。 Nokogiri对于什么库完全适合你的系统做出了一些奇怪的假设,并且总是失败:)不用说,如果没有该标志,它会尝试使用捆绑的库。 – mudasobwa 2014-10-31 14:01:09