2010-08-05 130 views
13

我是Ruby on Rails的新手。错误:rb_gc()上的交叉线程违规

我跑的时候我会通过创建一个博客教程使用Rails在终端如下:

$ rails blog 
[BUG] cross-thread violation on rb_gc() 
(null) 

Abort trap 

我如何确定这是什么错误消息意味着,以及如何解决它?

$ gem env 
RubyGems Environment: 
    - RUBYGEMS VERSION: 1.3.7 
    - RUBY VERSION: 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin10] 
    - INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8 
    - RUBY EXECUTABLE: /opt/local/bin/ruby 
    - EXECUTABLE DIRECTORY: /opt/local/bin 
    - RUBYGEMS PLATFORMS: 
    - ruby 
    - x86-darwin-10 
    - GEM PATHS: 
    - /opt/local/lib/ruby/gems/1.8 
    - /Users/sunpech/.gem/ruby/1.8 
    - GEM CONFIGURATION: 
    - :update_sources => true 
    - :verbose => true 
    - :benchmark => false 
    - :backtrace => false 
    - :bulk_threshold => 1000 
    - :sources => ["http://rubygems.org/", "http://gems.github.com"] 
    - REMOTE SOURCES: 
    - http://rubygems.org/ 
    - http://gems.github.com 

UPDATE

我做了一些摆弄,我不再收到错误消息。但我注意到现在我的环境正在运行一个不同的Ruby路径。

$ gem env 
RubyGems Environment: 
    - RUBYGEMS VERSION: 1.3.5 
    - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] 
    - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8 
    - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 
    - EXECUTABLE DIRECTORY: /usr/bin 
    - RUBYGEMS PLATFORMS: 
    - ruby 
    - universal-darwin-10 
    - GEM PATHS: 
    - /Library/Ruby/Gems/1.8 
    - /Users/sunpech/.gem/ruby/1.8 
    - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 
    - GEM CONFIGURATION: 
    - :update_sources => true 
    - :verbose => true 
    - :benchmark => false 
    - :backtrace => false 
    - :bulk_threshold => 1000 
    - :sources => ["http://rubygems.org/", "http://gems.github.com"] 
    - REMOTE SOURCES: 
    - http://rubygems.org/ 
    - http://gems.github.com 

这似乎暗示我在我的Mac机上安装了多个Ruby。一个在/ opt/local/bin /和/ usr/bin /中。我认为前者来自MacPorts安装,后者是我的系统(可能已升级)随附的内容。

+1

我得到了同样的错误。我认为这是我安装的宝石的问题。我擦掉了已安装的宝石,错误消失了。 巧合与否,你的工作与非工作版本中的创业板路径是不同的。 – 2012-02-17 02:19:16

回答

4

问题是我的系统上有多个安装/路径的红宝石。我相信Mac OS X Snow Leopard预装了红宝石。我犯了使用MacPorts安装更新版本的错误,与此同时。

我的解决了这一问题:

  1. 从MacPorts的
  2. 卸载红宝石的版本安装Ruby Version Manager,又名RVM,帮我管理多个红宝石安装。 (可选,但推荐)

我也在Ruby on Rails Talk上发布了这个。见Error: cross-thread violation on rb_gc()

4

我有一个类似的问题安装buildr宝石(使用rvm)。 This解决方案帮助:

I could nail this bug down to the native extensions of the ruby-java-bridge (rjb) on Mac OSX. What you want to do to fix this is the following:

gem uninstall rjb 
gem uninstall buildr 

When asked just uninstall all versions.

gem install rjb -v 1.3.3 --platform ruby 
gem install buildr 

This will install the ruby version of rjb and not the native darwin version. This should fix the issue.

Cheers Dominic

虽然,它没有涉及到的问题,这可能会帮助那些谁将会寻找相同的错误消息。

+0

这个固定的建造者也适合我。谢谢 – mawaldne 2012-05-12 15:28:10

10

这可能发生在各种各样的宝石上,并且似乎与使用C扩展编译的宝石不同,它试图加载它。

https://rvm.io/support/troubleshooting/

Bus Error/Segfault

[BUG] cross-thread violation on rb_gc() 

In every case of this I have seen thus far it has always ended up being that a ruby gem/library with C extensions was compiled against a different ruby and/or architecture than the one that is trying to load it. Try uninstalling & reinstalling gems with C extensions that your application uses to hunt this bugger down.

JSON的宝石是一种常见的罪魁祸首,但还有很长的人有问题,与其他宝石的名单。我不确定如何弄清究竟是哪个宝石造成了问题,但是如果你使用rvm和gemsets,你总是可以使用rvm gemset empty并用Bundler重新安装所有的宝石。

+1

好的建议 - 我把我的软件包安装了一半,一半用一个红宝石,一半用另一个,rvm gemset空了,正是它把事情弄清楚了。 – 2013-03-22 06:03:27