本文介绍了Mac用户并得到警告:Nokogiri是针对LibXML版本2.7.8构建的,但已动态加载2.7.3.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经进行了各种各样的研究,并尝试了许多不同的事情.我知道这个问题已经回答了很多次,但是没有建议的解决方案对我有用.

I have done all kinds of research and tried many different things. I know this question has been answered many times, but none of the suggested solutions are working for me.

升级到Lion之后,我在Ruby中遇到了分段错误.我非常有信心是Nokogiri.所以我通过Homebrew安装了libxml2.我跑了brew link libxml2.然后,我使用该版本的库重新安装了Nokogiri.

After upgrading to Lion I am getting segmentation faults in Ruby. I'm fairly confident it's Nokogiri. So I installed libxml2 via Homebrew. I ran brew link libxml2. Then I reinstalled Nokogiri using that version of the library.

为证明:

$ nokogiri -v
# Nokogiri (1.5.0)
---
warnings: []
nokogiri: 1.5.0
ruby:
  version: 1.9.2
  platform: x86_64-darwin11.0.0
  description: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]
  engine: ruby
libxml:
  binding: extension
  compiled: 2.7.8
  loaded: 2.7.8

我已经在我的gemfile的顶部包含了Nokogiri,并且在我的环境文件中也需要它.我不知道为什么我仍然收到该警告.

I've already included Nokogiri at the top of my gemfile and I've also required it in my environment file. I have no idea why I am still getting that warning.

是否有任何建议或想法来确保它正在加载正确的libxml2版本?

Any suggestions or ideas to make sure it's loading the right version libxml2?

推荐答案

我刚刚度过了大部分时间来解决此警告.此修复程序适用于使用Mac OS Lion的用户.上面使用

I just spent the better part of the morning working through this warning. This fix is for people using Mac OS Lion. The fix above using

bundle config build.nokogiri --with-xml2-include=/opt/local/include/libxml2 --with-xml2-lib=/opt/local/lib --with-xslt-dir=/opt/local

用于通过MacPorts安装libxml2的Snow Leopard.

is for Snow Leopard with libxml2 installed via MacPorts.

对于Lion,libxml2作为引导过程的一部分被加载.无论Nokogiri指向哪个libxml2,都会在运行时使用Lion系统的libxml2默认库. Lion使用/usr(不是/usr/local)中的libxml2.2.7.3.

With Lion, libxml2 is loaded as part of the bootstrap process. Regardless of which libxml2 Nokogiri is pointing to, the Lion system default library for libxml2 will be used at runtime. Lion uses libxml2.2.7.3 found in /usr (not /usr/local).

正如在许多其他地方所提到的,人们可以忽略该警告.如果像我一样,警告使您发疯,则可以执行以下操作:

As mentioned many other places, one can just ignore the warning. If, like me, the warning drives you crazy, you can do this:

bundle config build.nokogiri --with-xml2-dir=/usr --with-xslt-dir=/opt/local --with-iconv-dir=/opt/local

有趣的是,如果在命令行中键入nokogiri -v,则会收到相反的警告:

Interestingly, if you type nokogiri -v at the command line you will get the opposite warning:

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

这表明还有更多关于如何加载libxml2的信息,Ruby和Rails使用从系统路径加载的系统libxml2以及使用libxml2的命令行.无论如何,这对我来说是个错误.

This suggests there is more to how libxml2 is being loaded, with Ruby and Rails using the system loaded libxml2 and the command line using libxml2 from the environment path. Anyway, this silences the error for me.

我再说一遍-这仅适用于Lion.先前的修复程序将适用于Snow Leopard.

I’ll say it again – this is only for Lion. The previous fix will work for Snow Leopard.

这是答案的结尾.在这里停止阅读.

This is the end of the answer. Stop reading here.

好的,您没有停止阅读...好吧...

OK, you didn’t stop reading... well...

不推荐!!!!!!!

您已被警告.您可以通过禁用/usr/lib中的libxml2来验证Mac OSX是否在其引导程序中加载了libxml2库.做类似将libxml2*.dylib的所有版本复制到libxml2*.dylib.old的操作(在我的机器上是libxml2.2.7.3libxml2.2libxml2).

You have been warned. You can verify that Mac OSX is loading the libxml2 library in its bootstrap by disabling libxml2 found in /usr/lib. Do something like copying all versions of libxml2*.dylib to libxml2*.dylib.old (on my machine this was libxml2.2.7.3, libxml2.2 and libxml2).

完成此操作后,运行Nokogiri将不会产生任何错误.这是因为它找不到已加载的libxml2,并且现在会遵循环境路径,最终在/opt/local中找到libxml2.2.7.8.

After you have done this, running Nokogiri will not produce any errors. That is because it can’t find the loaded libxml2 and will now follow the environment path, eventually finding libxml2.2.7.8 in /opt/local.

但是您将无法将旧的libxml文件复制回去.这是因为操作系统需要在引导程序中加载的libxml2.

BUT you won’t be able to copy the old libxml files back. This is because the OS needs the libxml2 that was loaded in the bootstrap.

关闭电源并再次打开电源将使您的机器变砖.登录屏幕将挂起并挂起并挂起.关闭电源,然后以单用户模式重新打开电源(重新引导时按住-).您可以观看引导程序的发生.低,请注意,它引发了一个错误,导致它无法加载libxml2,然后停止工作.

Powering off and powering on again will brick your machine. The login screen will hang and hang and hang. Power off and power on again in single-user mode (hold - while rebooting). You can watch the bootstrap occur. Low and behold, it throws an error that it can’t load libxml2 and then stops working.

关闭电源,然后再次打开.这次引导进入恢复模式(按住-或按住,然后选择恢复磁盘).在恢复模式下,打开终端(utilities/terminal).将/usr/lib挂载到HD上(尝试/Volumes/Macintosh\ HD/usr/lib),然后将libxml2文件复制回去.重新启动,一切都会好起来.

Power off and power on again. This time boot into recovery mode (either hold - or hold and then select the recovery disk). In recovery mode open the terminal (utilities/terminal). Mount /usr/lib on your HD (try /Volumes/Macintosh\ HD/usr/lib) and copy the libxml2 files back. Reboot and all will be fine.

这篇关于Mac用户并得到警告:Nokogiri是针对LibXML版本2.7.8构建的,但已动态加载2.7.3.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 22:05