Nokogiri 是针对 LibXML 版本 2.7.7 构建的,但已动态加载 2.7.3 [英] Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.3

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

问题描述

在 Rails 3 中,我注意到每次调用框架时,无论是从 rakerails server 还是其他任何地方,我都会收到以下警告:

In Rails 3, I've noticed that every time I invoke the framework, whether from rake, rails server, or anything else, I get the following warning:

Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.3

在 Google 上搜索产生了一些博客文章,所有这些文章都建议使用显式库和包含路径重建 Nokogiri.例如:

Searching on Google yields a few blog posts, all of which suggest rebuilding Nokogiri using explicit lib and include paths. For example:

http://mrflip.github.com/2009-08/nokogiri-hates-libxml2-on-osx.html

但是,这并没有解决我的问题.

But, that didn't solve the problem for me.

输入 nokogiri -v 给我这个:

--- 
warnings: []

ruby: 
  engine: mri
  version: 1.8.7
  platform: i686-darwin10.4.0
libxml: 
  loaded: 2.7.7
  binding: extension
  compiled: 2.7.7
nokogiri: 1.4.4

这似乎表明我的构建运行正常,而且 Nokogiri 正在加载正确的库版本.那么为什么 Rails 会抱怨?

Which seems to suggest that my build went OK, and Nokogiri is loading the correct library versions. So why does Rails complain?

我实际上找到了答案,我想我会在这里分享.请看下面我的回答.

I actually found the answer, and I thought I'd share it here. See my answer below.

推荐答案

问题是其他库正在加载较早的 libxml 版本.我是通过在我的 Gemfile 中注释掉的东西发现的.具体来说,就我而言,RMagick 正在加载 libxml 2.7.3.(它使用 libxml 来读取 SVG 文件.)

The problem is that other libraries are loading the earlier libxml version. I found this by commenting things out in my Gemfile. Specifically, in my case RMagick was loading libxml 2.7.3. (It uses libxml to read SVG files.)

我尝试像这样针对 libxml 2.7.7 重建 RMagick:

I tried to rebuild RMagick against libxml 2.7.7 like so:

gem install --no-rdoc --no-ri rmagick -- --with-xml2-include=/opt/local/include/libxml2 --with-xml2-lib=/opt/local/lib --with-xslt-include=/opt/local/libxslt --with-xslt-lib=/opt/local/lib

然而,RMagick 似乎并不关心这些标志.它再次使用 2.7.3 构建.(如果有人知道如何针对特定的 libxml 版本构建 RMagick,请分享您的知识.)

However, RMagick did not seem to care about those flags. It built using 2.7.3 again. (If anyone knows how to build RMagick against a specific libxml version, please do share your knowledge.)

最终,我确实找到了一个半途而废的解决方案.我决定,如果我无法解决这两个 gem 之间的版本冲突,我至少会支持 Nokogiri,它使用较新版本的 libxml.为此,我找出了 Gemfile 中哪些 gem 使用了 Nokogiri 并将它们放在首位.

Ultimately, I did find a halfway-decent solution. I decided that if I couldn't resolve the version conflict between these two gems, I'd at least favor Nokogiri, which uses a newer version of libxml. To do that, I figured out which gems in my Gemfile were using Nokogiri and put them first.

所以,虽然我曾经有过这个:

So, whereas I once had this:

gem 'rmagick', :require => 'RMagick'
gem 'sanitize' # Has Nokogiri as dependency

我现在有这个:

gem 'sanitize' # Has Nokogiri as dependency
gem 'rmagick', :require => 'RMagick'

现在警告消失了,RMagick 还没有抱怨.免责声明:我没有在我的应用程序中使用 SVG,所以我还没有确认 RMagick 与 libxml 2.7.7 完全兼容.

Now the warning is gone, and RMagick hasn't yet complained. Disclaimer: I don't use SVGs in my apps, so I haven't confirmed that RMagick is fully compatible with libxml 2.7.7.

这篇关于Nokogiri 是针对 LibXML 版本 2.7.7 构建的,但已动态加载 2.7.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆