升级到 ruby 1.9.2 并在 nokogiri 中出现分段错误错误
我昨天决定升级到 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您从 nokogiri 收到分段错误错误,例如,当您打开 Rails 控制台时,您正在使用 RVM,并且您的 ruby 版本是 1.9.2 左右(我的当前版本是 1.9.2p136),并且您会注意到对 ruby 1.8 的引用。 7 就在 nokogiri 分段错误消息之后,那么以下内容可能会有所帮助...
错误
解决方案
(1) 确保 ruby 1.8.7 不是 rvm ruby 版本:
- 运行
rvm列表
(2) 卸载 nokogiri 和 libxml2 相关依赖项:
(3) 使用 homebrew 安装 libxml2
(4) 从源代码安装 libxslt
(5) 安装 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) 测试
获取并保存 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
SOLUTION
(1) make sure that ruby 1.8.7 is not a rvm ruby version:
- run
rvm list
(2) uninstall nokogiri and libxml2 related dependencies:
(3) install libxml2 using homebrew
(4) install libxslt from source
(5) 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
Getting and keeping your Ruby XML parsing libraries running properly can be an issue. Here are some alternatives: LibXML, Hpricot, REXML
我猜你只需要告诉
rvm
使用正确的 ruby 即可。否则为什么你的第二行会显示 1.8.7?
您不应该期望针对一个主要版本的 ruby 编译的本机代码能够干净地链接到另一个版本。据我所知,没有 ABI 合同。
I'm guessing you just need to tell
rvm
to use the correct ruby.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.
您是否有可能最初在 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 bygem 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.
尝试在终端中运行
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.
这里的所有建议对我来说都不起作用,但是这个问题的删节答案 作者:mmrobins 下面:
然后是标准捆绑安装,一切都对我有用。
all the suggestions here didn't work for me, but the abridged answer to this issue by mmrobins below:
followed by a standard bundle install got everything working for me.