【问题标题】:Segmentation Fault in rvm'd Ruby on Mac when running RSpec运行 RSpec 时,Mac 上 rvm'd Ruby 中的分段错误
【发布时间】:2010-07-24 16:37:54
【问题描述】:

我正在大学里开发一些东西,保存到我的 Dropbox 打算继续在家。这是迎接我的消息:

$ spec graph_spec.rb 
/Users/amadan/.rvm/gems/ruby-1.9.2-rc1/gems/PriorityQueue-0.1.2/ext/priority_queue/CPriorityQueue.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

然而,

$ `which spec` graph_spec.rb 
...........................................................................

Finished in 0.046973 seconds

75 examples, 0 failures

这到底是怎么回事?

供参考:

$ which spec
/Users/amadan/.rvm/gems/ruby-1.9.2-rc1/bin/spec

更新:我刚刚注意到那里的 1.8.7……它是如何到达那里的?规范文件的顶部说:

$ head `which spec`
#!/Users/amadan/.rvm/rubies/ruby-1.9.2-rc1/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

它在哪里说“运行 1.8.7”?!?

【问题讨论】:

  • 你需要出示你的 $PATH 才能得到答案。
  • which 给出$PATH 中的第一个文件。之后,ruby 应该通过 hash-bang 行中的绝对路径加载。因此,在我能想到的唯一地方$PATH 是相关的,我通过which spec 命令的输出提供了足够的信息。

标签: ruby rspec segmentation-fault gem rvm


【解决方案1】:

RVM 很可能正在弄乱您的宝石和红宝石。我建议在已清理的 RVM 安装上进行测试(仅安装 1.9)。

/Users/amadan/.rvm/rubies/ruby-1.9.2-rc1/bin/ruby真的是 ruby​​ 1.9.2 吗?

其他测试方法是显式运行ruby spec,这样您就可以确定这确实是调用的 1.9.2。

总而言之,在 ruby​​ 中确实会发生 Segfaults(尤其是在 1.8 上),有时可以通过稍微重组 ruby​​ 代码来避免。祝你好运!

【讨论】:

  • 感谢您的评论。我会将此标记为正确的,因为我也认为 RVM 发生了一些奇怪的事情,但事实上这个问题在这一年变得无关紧要......我仍然对发生的事情同样感到困惑,我只是不'不需要再解决了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-14
  • 1970-01-01
  • 2012-04-28
  • 1970-01-01
  • 2013-10-31
相关资源
最近更新 更多