升级到 ruby​​ 1.9.2 并在 nokogiri 中出现分段错误错误

发布于 2024-10-02 13:08:07 字数 379 浏览 4 评论 0原文

我昨天决定升级到 1.9.2 ruby​​,并且还安装了 rvm 来执行此操作。我运行了一些我之前在 1.8.7 上工作过的最新文件,但任何需要 nokogiri 的操作都会失败,并出现以下错误。

/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 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]

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

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

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

发布评论

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

评论(5

厌倦 2024-10-09 13:08:07

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

错误

$ 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列表

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

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

$ gem uninstall nokogiri
$ brew uninstall libxml2

(3) 使用 homebrew 安装 libxml2

$ brew install libxml2
$ brew link libxml2

(4) 从源代码安装 libxslt

$ 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

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

(6) 测试

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

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

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...

ERROR

$ 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

SOLUTION

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

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

(2) uninstall nokogiri and libxml2 related dependencies:

$ gem uninstall nokogiri
$ brew uninstall libxml2

(3) install libxml2 using homebrew

$ brew install libxml2
$ brew link libxml2

(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) install nokogiri

gem install nokogiri

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) test

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

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

趴在窗边数星星i 2024-10-09 13:08:07

我猜你只需要告诉 rvm 使用正确的 ruby​​ 即可。

rvm 1.9.2

否则为什么你的第二行会显示 1.8.7?

您不应该期望针对一个主要版本的 ruby​​ 编译的本机代码能够干净地链接到另一个版本。据我所知,没有 ABI 合同。

I'm guessing you just need to tell rvm to use the correct ruby.

rvm 1.9.2

Otherwise why would your second line indicate 1.8.7?

You shouldn't expect native code compiled against one major version of ruby to link cleanly to another. There's no ABI contract, afaik.

拒绝两难 2024-10-09 13:08:07

您是否有可能最初在 Leopard 上构建 Nokogiri,然后升级到 Snow Leopard?

如果是这样,请执行gem uninstall nokogiri,然后执行gem install nokogiri。这将迫使它为您当前选择的 Ruby 和操作系统重新编译。

当我从 Leopard 升级到 Snow Leopard 并重新安装 Ruby 时,我看到了类似的问题。这些宝石没有被重新编译,所以我不得不强迫其中的几个宝石这样做。

Is it possible you originally built Nokogiri on Leopard then upgraded to Snow Leopard?

If so, do a gem uninstall nokogiri followed by gem install nokogiri. That will force it to recompile for your currently selected Ruby and OS.

I saw the similar problems when I upgraded from Leopard to Snow Leopard, and reinstalled my Ruby. The gems didn't get recompiled, so I had to force several of them to do so.

缪败 2024-10-09 13:08:07

尝试在终端中运行 rvmrequirements 并查看是否缺少任何依赖项。 (它在我的 OS X 中显示为红色)

返回的注释帮助我使用brew 安装缺少的依赖项,并明确说明了步骤。

Try running rvm requirements in Terminal and see if there are any missing dependencies. (It shows in red in my OS X)

The returned notes helped me install missing dependencies with brew, with clearly stated steps.

惜醉颜 2024-10-09 13:08:07

这里的所有建议对我来说都不起作用,但是这个问题的删节答案 作者:mmrobins 下面:

rvm gemset empty

然后是标准捆绑安装,一切都对我有用。

all the suggestions here didn't work for me, but the abridged answer to this issue by mmrobins below:

rvm gemset empty

followed by a standard bundle install got everything working for me.

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