我正在尝试安装 nokogiri 1.6.0 版,但遇到了一些问题。
$ 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"
希望对您有所帮助。
关于ruby-on-rails - Gem 安装忽略 nokogiri 的标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26675271/