如何在 Ubuntu 上修复 Nokogiri? [英] How to fix Nokogiri on Ubuntu?

查看:48
本文介绍了如何在 Ubuntu 上修复 Nokogiri?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的工作站上使用 ruby​​ 2.0.0 运行 Ubuntu 13.04,它是通过 RVM 安装的.

I run Ubuntu 13.04 on my workstation with ruby 2.0.0, which was installed via RVM.

$ aptitude 显示 libxml2

$ aptitude show libxml2

<代码>包:libxml2
状态:已安装自动安装:否多拱:相同版本:2.9.0+dfsg1-4ubuntu4.1

$ aptitude show libxml2-dev

$ aptitude show libxml2-dev

<代码>包:libxml2-dev
状态:已安装自动安装:否多拱:相同版本:2.9.0+dfsg1-4ubuntu4.1

$ aptitude show libxslt-dev

$ aptitude show libxslt-dev

<代码>包:libxslt1-dev
状态:已安装自动安装:否版本:1.1.27-1ubuntu2优先级:可选

$ nokogiri -v

$ nokogiri -v

<代码>警告:Nokogiri 是针对 LibXML 版本 2.9.0 构建的,但已动态加载 2.8.0# Nokogiri (1.6.0)---警告:- Nokogiri 是针对 LibXML 版本 2.9.0 构建的,但已动态加载 2.8.0nokogiri:1.6.0红宝石:版本:2.0.0平台:x86_64-linux描述:ruby 2.0.0p195 (2013-05-14 修订版 40734) [x86_64-linux]发动机:红宝石库文件:绑定:扩展来源:打包libxml2_path:/home/pb/.rvm/gems/ruby-2.0.0-p195/gems/nokogiri-1.6.0/ports/x86_64-linux-gnu/libxml2/2.8.0libxslt_path:/home/pb/.rvm/gems/ruby-2.0.0-p195/gems/nokogiri-1.6.0/ports/x86_64-linux-gnu/libxslt/1.1.26编译:2.9.0加载:2.8.0

我使用命令安装了 nokogiri,因为否则它使用的是 libxml2 2.8.0 版,但我不确定它来自哪里,因为只是通过 apt 安装了 libxml2.

I installed nokogiri with the command, because else it's using libxml2 version 2.8.0, but I'm not sure where it takes this from, since just libxml2 is installed via apt.

<代码>gem install nokogiri -- --with-xml2-include=/usr/include/libxml2/libxml --with-xslt-dir=/usr/include/libxslt

当我运行我的应用程序时,我收到以下错误:

When I run my application I get the following error:

<代码>/home/pb/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in require':/home/pb/.rvm/gems/ruby-2.0.0-p195/gems/nokogiri-1.6.0/ports/x86_64-linux-gnu/libxml2/2.8.0/lib/libxml2.so.2:版本LIBXML2_2.9.0' 未找到(/home/pb/.rvm/gems/ruby-2.0.0-p195/gems/libxml-ruby-2.6.0/lib/libxml_ruby.so 需要) -/home/pb/.rvm/gems/ruby-2.0.0-p195/gems/libxml-ruby-2.6.0/lib/libxml_ruby.so (LoadError)

/home/pb/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in require': /home/pb/.rvm/gems/ruby-2.0.0-p195/gems/nokogiri-1.6.0/ports/x86_64-linux-gnu/libxml2/2.8.0/lib/libxml2.so.2: versionLIBXML2_2.9.0' not found (required by /home/pb/.rvm/gems/ruby-2.0.0-p195/gems/libxml-ruby-2.6.0/lib/libxml_ruby.so) - /home/pb/.rvm/gems/ruby-2.0.0-p195/gems/libxml-ruby-2.6.0/lib/libxml_ruby.so (LoadError)

谁能告诉我如何摆脱 libxml2 2.8.0 版?

Can anyone tell me how I get rid of libxml2 version 2.8.0?

谢谢

推荐答案

Nokogiri 默认使用自己的 libxml 版本.可能是因为 Mac OS 提供了一个 2001 年 (!) 的 libxml 版本,而旧库不提供 Nokogiri 所依赖的功能.但是,这可能会导致保持最新的系统出现问题.要解决此问题,您需要针对您的操作系统提供的库构建 Nokogiri.

Nokogiri is using its own version of libxml by default. Probably because Mac OS provides a version of libxml that is dated 2001 (!), and old libraries don't provide features Nokogiri depends on. However, this may cause a problem with the systems that are kept up-to-date. To resolve the problem you need to build Nokogiri against the libraries your OS provides.

这可能是这样的,它来自 Arch Linux:

This maybe something like this, it's from Arch Linux:

gem install nokogiri -- \
  --with-xml2-include=/usr/include/libxml2/libxml \
  --with-xml2-lib=/usr/lib \
  --with-xslt-include=/usr/include/libxslt \
  --with-xslt-lib=/usr/lib

如果使用 Ubuntu 或 Fedora 等发行版,您可能需要安装开发包.在 Ubuntu 上应该是 libxml2-devlibxslt1-dev 但如果我错了,请纠正我.

You may need to install development packages if using distros like Ubuntu or Fedora. It should be libxml2-dev and libxslt1-dev on Ubuntu but correct me if I'm wrong.

这篇关于如何在 Ubuntu 上修复 Nokogiri?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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