升级到 ruby​​ 1.9.2 并在 nokogiri 中出现分段错误错误 [英] Upgraded to ruby 1.9.2 and getting Segmentation Fault errors in nokogiri

查看:10
本文介绍了升级到 ruby​​ 1.9.2 并在 nokogiri 中出现分段错误错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天决定升级到 1.9.2 ruby​​ 并且还安装了 rvm 来做到这一点.我运行了一些最近在 1.8.7 上工作过的文件,但任何需要 nokogiri 的文件都失败并出现以下错误.

I decided to upgrade to 1.9.2 ruby yesterday and also installed rvm to do it. I ran a few recent files I had working previously on 1.8.7 but anything requiring nokogiri fails with the following errors.

/Users/myusername/.rvm/gems/ruby-1.9.2-p0/gems/nokogiri-1.4.3.1/lib/nokogiri/nokogiri.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

我在 OSX Snow Leopard 10.6.4 上运行 nokogiri 1.4.3.1、ruby 1.9.2

I am running nokogiri 1.4.3.1, ruby 1.9.2 on OSX Snow Leopard 10.6.4

推荐答案

如果您从 nokogiri 收到 Segmentation fault 错误,例如,当您打开 rails 控制台时,您使用的是 RVM 并且您的 ruby​​ 版本是 1.9.2 左右(我目前是 1.9.2p136)并且您在 nokogiri 分段错误消息之后注意到对 ruby​​ 1.8.7 的引用,那么也许以下内容可能会有所帮助...

If you get a Segmentation fault error from nokogiri, e.g., when you open your rails console, and you are using RVM and your ruby version is 1.9.2 something (mine currently is 1.9.2p136) and you notice a reference to ruby 1.8.7 just after the nokogiri segmentation fault message, then perhaps the following may be of assistance...

错误

$ rails c
/Users/lex/.rvm/gems/ruby-1.9.2-p136@lmi/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

Abort trap

解决方案

(1) 确保 ruby​​ 1.8.7 不是 rvm ruby​​ 版本:- 运行 rvm 列表

(1) make sure that ruby 1.8.7 is not a rvm ruby version: - run rvm list

如果是,则将其删除:例如:rvm uninstall ree-1.8.7-2010.02

if it is, then remove it: ex: rvm uninstall ree-1.8.7-2010.02

(2)卸载nokogiri和libxml2相关依赖:

(2) uninstall nokogiri and libxml2 related dependencies:

$ gem uninstall nokogiri
$ brew uninstall libxml2

(3) 使用自制软件安装 libxml2

(3) install libxml2 using homebrew

$ brew install libxml2
$ brew link libxml2

(4) 从源代码安装 libxslt

(4) install libxslt from source

$ wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
$ tar -zxvf libxslt-1.1.26.tar.gz
$ cd libxslt-1.1.26
$ ./configure --prefix=/usr/local/Cellar/libxslt/1.1.26    --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.7
$ make
$ sudo make install

(5) 安装 nokogiri

(5) install nokogiri

gem install nokogiri

替代方案(确保您的路径正确):gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.7/include --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.7/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26

Alternative (ensure your paths are correct): gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.7/include --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.7/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26

(6) 测试

$ rails c
Loading development environment (Rails 3.0.3)
>>

获取并保持 Ruby XML 解析库正常运行可能是个问题.以下是一些替代方案:LibXML、Hpricot、REXML

Getting and keeping your Ruby XML parsing libraries running properly can be an issue. Here are some alternatives: LibXML, Hpricot, REXML

这篇关于升级到 ruby​​ 1.9.2 并在 nokogiri 中出现分段错误错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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