在Snow Leopard上安装一些宝石的错误 - libxml2

时间:2010-01-16 00:53:26

标签: macos rubygems development-environment osx-snow-leopard macports

升级到Snow Leopard后,我发现安装一些宝石不再有效,包括webrat,mechanize等。每次我都会收到此错误:

checking for xmlParseDoc() in -lxml2... no
libxml2 is missing.  try 'port install libxml2' or 'yum install libxml2'
*** 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.

不,我没有尝试用macports安装它,因为几年前,当我发现我无法轻易降级/管理端口时,我放弃了macports。从那时起,我已经变得非常舒适地从手工来源建造,这是我第一次遇到超出我的肯定的东西。我愿意被说服回到m​​acports,但只有在没有简单解决方案的情况下我才会失踪。

似乎libxml2实际上没有丢失,或许只是过时了?...

扩展输出

ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
checking for iconv.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libxml/parser.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libxslt/xslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libexslt/exslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for xmlParseDoc() in -lxml2... no
libxml2 is missing.  try 'port install libxml2' or 'yum install libxml2'
*** 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
    --without-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=/usr/local/bin/ruby
    --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
    --without-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-xml2lib
    --without-xml2lib


Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.4.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.4.1/ext/nokogiri/gem_make.out

3 个答案:

答案 0 :(得分:1)

<强>更新

正如另一个答案中所述,以下解决方案是“过度杀伤”,因为它会从您的系统中删除MacPorts,我认为我之前已经这样做了。继续仔细。可能有一种方法可以使用MacPorts来更新libxml2安装。


我解决了这个问题(至少在我的机器上)。

一旦我意识到该跟踪中没有任何内容表明缺少libxml2,而是检测到版本的问题,我四处寻找确认这一事实。果然,nokogiri website(许多类似的错误报告指出了我)毫不含糊地指出Snow Leopard附带了一个良好的libxml2工作版本。

因此,我推断我必须在很久以前通过其他方式安装版本。我会记得,如果我手动安装,那么实际上只剩下一个选项,frickin'macports。

$ libxml2-2.7.1 tfwright$ sudo find / -type d -name "libxml2" 
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/libxml2
/Developer/SDKs/MacOSX10.5.sdk/usr/include/libxml2
/Developer/SDKs/MacOSX10.6.sdk/usr/include/libxml2
/opt/local/include/libxml2
/opt/local/share/gtk-doc/html/libxml2
/opt/local/var/macports/distfiles/libxml2
/opt/local/var/macports/receipts/libxml2
/opt/local/var/macports/software/libxml2
/opt/local/var/macports/software/libxml2/2.6.30_0/opt/local/include/libxml2
/opt/local/var/macports/software/libxml2/2.6.30_0/opt/local/share/gtk-doc/html/libxml2
/opt/local/var/macports/sources/rsync.macports.org/release/ports/textproc/libxml2
/usr/include/libxml2
/usr/share/gtk-doc/html/libxml2

儿子......刚刚吹走/opt/local/var/macports,我首先尝试过,似乎没有解决问题,所以我去了big guns

sudo rm -rf \
/opt/local \
/Applications/DarwinPorts \
/Applications/MacPorts \
/Library/LaunchDaemons/org.macports.* \
/Library/Receipts/DarwinPorts*.pkg \
/Library/Receipts/MacPorts*.pkg \
/Library/StartupItems/DarwinPortsStartup \
/Library/Tcl/darwinports1.0 \
/Library/Tcl/macports1.0 \
~/.macports

之后,一切安装都很好。那就对了。永远不要相信错误消息的建议!我不需要重新安装带有macports的libxml2,我需要擦除我系统中的所有macports痕迹,这让我从垃圾箱中萦绕不去。

答案 1 :(得分:1)

floyd的解决方案是矫枉过正 - 我遇到了同样的问题并开始查找与xml2相关的一些相同的/ opt / local文件,但是他的'find'命令没有显示opt / local / lib中的实际libxml2文件。可能你需要核对这些。

以下是我的核心文件:

/opt/local/include/libxml2
/opt/local/var/db/dports/distfiles/libxml2
/opt/local/var/db/dports/receipts/libxml2
/opt/local/var/db/dports/software/libxml2
/opt/local/var/db/dports/rsync.rsync.darwinports.org_dpupdate_dports/textproc/libxml2
/opt/local/share/gtk-doc/html/libxml2
/opt/local/var/db/dports/sources/rsync.rsync.darwinports.org_dpupdate_dports/textproc/libxml2

但在你尝试之前 - 只需核对lib文件 sudo rm / opt / local / lib / libxml2。*

当我尝试安装之后,它进行了全部编译,但随后又解决了libz的问题......

所以在/ opt / local / lib中进行核实 sudo rm -rf / opt / local / lib / libz。*

它编译得很好!

请尝试查看/ opt / local / lib libxml2。*和libz。*文件,查看是否编译,如果没有,请查看/ opt / local / includes

答案 2 :(得分:0)

您尝试安装的gem需要libxml2。如果您愿意从源代码安装,请安装libxml2

您可能遇到依赖性问题,其中libxml2依赖于您需要手动构建和安装的一堆其他软件包。这就是为什么macports最终有用的原因之一。