【问题标题】:Errors installing some gems on Snow Leopard - libxml2在 Snow Leopard - libxml2 上安装一些 gem 时出错
【发布时间】:2011-01-05 18:06:09
【问题描述】:

升级到雪豹后,我发现安装一些gem不再起作用,包括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。从那时起,我已经非常习惯于从源代码手工构建,这是我第一次遇到超出我知识范围的东西。我愿意被说服回到 macports,但前提是没有简单的解决方案。

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

【问题讨论】:

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


    【解决方案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 的痕迹,这让我在垃圾堆之外一直困扰着我。

    【讨论】:

      【解决方案2】:

      floyd 的解决方案有点矫枉过正——我遇到了同样的问题并开始对一些与 xml2 相关的相同 /opt/local 文件进行核对,但他的“查找”命令并未显示 opt/local/lib 中的实际 libxml2 文件。可能你只需要核对那些。

      这是我的 nuked 文件:

      /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

      【讨论】:

        【解决方案3】:

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

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

        【讨论】:

        • 我说的超出了我的理解范围,因为似乎没有任何权威指南可以从源代码安装 libxml2。以我的经验,在没有一些指导的情况下,有太多隐藏的陷阱无法冒险。你提到的依赖问题正是我所说的。你是说在这种情况下有这么多的依赖关系,制定一个简单的配方是不合理的,比如那些存在于 SQL、ruby 等(hivelogic 指南)的配方?
        猜你喜欢
        • 2011-03-10
        • 2012-02-24
        • 1970-01-01
        • 2011-01-25
        • 2011-05-16
        • 2013-02-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多