OS X Lion,尝试安装 Nokogiri - 缺少 libxml2 [英] OS X Lion, Attempting Nokogiri install - libxml2 is missing
问题描述
sudo gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/sajeev86/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for libxml/parser.h... 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.
我无法安装 Nokogiri.这已经让我负担了一段时间了.我也通过 MacPorts 和 Homebrew 安装了依赖项.
I can't get Nokogiri to install. This has been taxing me for a while now. I've installed the dependencies via MacPorts and Homebrew as well.
我有一种感觉,正确的目录没有相互指向?但不知道如何修复.
I've got a feeling the right directories are not pointed to each other? But haven't a clue how to fix.
推荐答案
在 Mavericks 中,使用 Homebrew 安装库并在安装 gem 之前设置 NOKOGIRI_USE_SYSTEM_LIBRARIES=1
对我有用.
In Mavericks, installing the libraries with Homebrew and setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1
before installing the gem did the trick for me.
总结:
如果之前安装过,请卸载 gem:
$ gem 卸载 nokogiri
使用 Homebrew 安装 libxml2
、libxslt
和 libiconv
:$ brew install libxml2 libxslt libiconv
Use Homebrew to install libxml2
, libxslt
and libiconv
:
$ brew install libxml2 libxslt libiconv
安装 gem,指定要链接到的库的路径:$ 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"
Install the gem specifying the paths to the libraries to be linked against:
$ 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"
这篇关于OS X Lion,尝试安装 Nokogiri - 缺少 libxml2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!