在 Snow Leopard 上安装一些 gem 时出错 - libxml2

发布于 2024-08-18 05:32:21 字数 3234 浏览 2 评论 0 原文

升级到 Snow Leopard 后,我发现安装一些 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

After upgrading to Snow Leopard, I found that installing some gems no longer worked, including webrat, mechanize etc. Each time I get this error:

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.

And no, I haven't tried installing it with macports, because I forswore macports a couple years back when I discovered I couldn't easily downgrade/manage ports. Since then, I have become very comfortable building from source by hand, and this is the first time I've run into something beyond my ken. I am willing to be persuaded to go back to macports, but only if there's no easy solution to this I am missing.

It doesn't appear that libxml2 is actually missing, just out of date perhaps?...

extended output

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

云柯 2024-08-25 05:32:21

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.* 文件进行 nuke,看看它是否可以编译,如果不能,则对 /opt/local/includes 进行 nuke

floyd's solution is overkill - I had the same issue and started nuking some of the same /opt/local files related to xml2, but his 'find' command does not reveal the actual libxml2 files in opt/local/lib. It may be that you just need to nuke those.

Here are my nuked files:

/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

BUT before you try that - just nuke the lib files
sudo rm /opt/local/lib/libxml2.*

When I tried to install after that it got into compiling it all but then barfed with an issue with libz...

So nuke that in /opt/local/lib
sudo rm -rf /opt/local/lib/libz.*

And it compiles just fine!

So try nuking the /opt/local/lib libxml2.* and libz.* files, see if it compiles and if not, nuke the /opt/local/includes

書生途 2024-08-25 05:32:21

更新

正如另一个答案中所述,下面的解决方案是“过度杀伤”,因为它从您的系统中删除了 MacPorts,我认为我之前已经完成了。小心行事。可能有一种方法可以使用 MacPorts 来更新 libxml2 安装。


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

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

因此,我推断我一定是很久以前通过其他方式安装了一个版本。我会记得如果我是手动安装的,那么实际上就只剩下一个选项了,该死的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,我首先尝试过,似乎没有解决问题,所以我去了 大炮

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 的所有痕迹,这一直困扰着我。

UPDATE

As stated in another answer, the below solution is 'overkill' because it removes MacPorts from your system, which I thought I had already done earlier. Proceed carefully. There may be a way to use MacPorts to just update the libxml2 install.


I solved this problem (on my machine at least).

Once I realized that nothing in that trace suggested the lack of libxml2, but rather a problem with the version being detected, I looked around for confirmation of this fact. Sure enough, the nokogiri website (where many similar bug reports pointed me) states in no uncertain terms that Snow Leopard ships with a good working version of libxml2.

Thus, I reasoned that I must have installed a version by another means long ago. I would remember if I had installed by hand, so there was really only one option left, 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

Son of a...just blowing away /opt/local/var/macports, which I tried first of all, didn't seem to fix the problem, so I went to the 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

After which, everything installs fine. that's right. Never trust the recommendations of error messages! Far from needing to reinstall libxml2 with macports, I needed to scrub away all traces of macports from my system, which was haunting me from beyond the trash.

雨落星ぅ辰 2024-08-25 05:32:21

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

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

The gems you are trying to install require libxml2. If you're comfortable installing from source, install libxml2.

You may run into dependency issues where libxml2 depends on a bunch of other packages that you'll need to build and install manually. That's one reason why macports ends up being useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文