Error: cross-thread violation on rb_gc()

后端 未结 3 1254
既然无缘
既然无缘 2021-01-04 07:40

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         


        
相关标签:
3条回答
  • 2021-01-04 07:43

    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.

    0 讨论(0)
  • 2021-01-04 07:52

    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.

    0 讨论(0)
  • 2021-01-04 08:01

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

    0 讨论(0)
提交回复
热议问题