使用新的libxml2帮助安装nokogiri

时间:2011-04-13 22:48:53

标签: ruby

我在nokogiri中收到以下错误。我正在安装新的库 libxml2通过fink,当我输入“fink list libxml2”时,我得到:

i   libxml2          2.7.8-102    XML parsing library, version 2

我也将我的.Profile添加到DY_LIBRARY_PATH ... / sw / lib中 尝试运行我的程序我收到以下警告:

WARNING: Nokogiri was built against LibXML version 2.6.16, but has dynamically loaded 2.7.8

如何安装该gem以便它链接到较新的libxml2库?我安装了 宝石为:

sudo gem install nokogiri

泰德

3 个答案:

答案 0 :(得分:1)

您已阅读“Nonstandard libxml2 / libxslt installations”了吗?

Fink是Mac OS上的非标准安装。

根据Nokogiri安装文档:

If you’ve got libxml2 and/or libxslt installed in a nonstandard place (read as “not /opt/local, /usr/local, /usr or the standard Ruby directories”), you can use command-line parameters to the gem install command to grease the wheels:

gem install nokogiri -- --with-xml2-dir=/home/joe/builds \
                        --with-xslt-dir=/home/joe/builds

Or, you can specify include and library directories separately:

gem install nokogiri -- --with-xml2-lib=/home/joe/builds/lib \
                        --with-xml2-include=/home/joe/builds/include/libxml2 \
                        --with-xslt-lib=/home/joe/builds/lib \
                        --with-xslt-include=/home/joe/builds/include

Note that, by default, libxslt header files are installed into the root include directory, but libxml2 header files are installed into a subdirectory thereof named libxml2.

答案 1 :(得分:0)

来自nokogiri wiki

  

指定libxml2和libxslt目录   对于安装程序。如果你正在使用   芬克:

gem install nokogiri -- --with-xml2-include=/sw/include/libxml2 --with-xml2-lib=/sw/lib --with-xslt-dir=/sw

答案 2 :(得分:0)

问题的根源是sudo。如果您在正确配置的环境中运行它,nokogiri非常容易安装而无需任何自定义标志。类似帖子中的详细信息:https://stackoverflow.com/a/30603620/145046