13

I'm new to Ruby on Rails.

I ran the following in a terminal when I was going through creating a blog tutorial with Rails:

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

Abort trap

How do I determine what this error message means and how to fix it?

$ 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

I did some fiddling and I'm not getting the error message anymore. But I do notice that my environment is running a different path of Ruby now.

$ 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

This seems to imply that I have multiple installs of Ruby on my Mac box. One in /opt/local/bin/ and /usr/bin/. I think the former came from a MacPorts install, and the latter is what came with my system (possibly upgraded).

1
  • 1
    I was getting the same error. I think that it was a problem with my installed gems. I wiped out the installed gems and the error went away. Coincidentally or not, the GEM PATHS in your working vs non-working versions are different. Feb 17, 2012 at 2:19

3 Answers 3

10

This can happen with all sorts of gems and seems to have to do with a gem with C extensions compiled against a different ruby than the one trying to load it.

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.

The json gem is a frequent culprit, but there's a long list of other gems that people have had issue with. I'm not sure how to figure out exactly which gem is causing the problem, but if you're using rvm with gemsets you, can always rvm gemset empty and reinstall all your gems with Bundler.

1
  • 1
    Good suggestion - I had mucked up my bundle install and half with one ruby and half with another and rvm gemset empty was exactly what it took to straighten things out. Mar 22, 2013 at 6:03
4

The problem was that I had multiple installs/paths of ruby on my system. Mac OS X Snow Leopard comes with ruby pre-installed I believe. I made the mistake of using MacPorts to install a newer version, right alongside.

I fixed the problem by:

  1. Uninstalling the version of ruby from Macports
  2. Installing Ruby Version Manager, aka rvm, to help me manage multiple ruby installs. (optional, but recommended)

I also posted this on Ruby on Rails Talk. See Error: cross-thread violation on rb_gc()

4

I had a similar problem installing buildr gem (using rvm). This solution helped:

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

Although, it's not related to the question, this may help those who will look for the same error message.

1
  • This fixed buildr for me as well. Thanks
    – mawaldne
    May 12, 2012 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.