Error: cross-thread violation on rb_gc()

I don’t like cross-posting, but there doesn’t seem to be much activity/
response to my question on StackOverflow.

Link to SO:

Question:

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?

Is there something wrong with a gem installed?

$ gem list

*** LOCAL GEMS ***

actionmailer (2.3.8)
actionpack (2.3.8)
activerecord (2.3.8)
activeresource (2.3.8)
activesupport (2.3.8)
colored (1.2)
crack (0.1.8)
json (1.4.3)
pusher (0.5.3)
rack (1.2.1, 1.1.0)
rails (2.3.8)
rake (0.8.7)
ruby-hmac (0.4.0)
signature (0.1.1, 0.1.0)
sinatra (1.0)
sqlite3-ruby (1.3.1, 1.3.0)
webmat-git_remote_branch (0.3.0)

$ 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:
  • REMOTE SOURCES:

I think I did install multiple instances of Ruby. How can I tell?
And how can I remove the extra?

Yes, I believe I did install one via MacPorts, and another manually.
I’m also new to Macs.

On 9 August 2010 03:23, Spong [email protected] wrote:

blog tutorial with Rails:

crack (0.1.8)

This smells like a borked Ruby installation, or multiple Ruby
installations conflicting with each other, or something like that.

Have you installed Ruby multiple times? How did you install the Ruby
you’re using in /opt/local/bin? MacPorts, I’m guessing?

Chris

I did some fiddling and this is what I’m getting:

$ 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:
  • REMOTE SOURCES:

So ruby seems to be installed in two place: /usr/bin/ and /opt/local/
bin. The former is the ruby that came with my Mac, and the latter
from MacPorts. Should I not use MacPorts to install/update ruby?

Spong wrote:
[…]

So ruby seems to be installed in two place: /usr/bin/ and /opt/local/
bin. The former is the ruby that came with my Mac, and the latter
from MacPorts. Should I not use MacPorts to install/update ruby?

The Ruby that comes with Leopard is perfectly adequate (it’s what I’m
using for development), unless you specifically want a newer version.
Some people like to install through Ports or Fink or build it themselves
regardless, but I think that’s just a waste of time and disk space.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

What Marnen said. Also, if you want to test stuff with multiple
versions of Ruby, rvm is an easy way to automatically install and
isolate different versions of Ruby on the same machine.

http://rvm.beginrescueend.com/

Nat

On 10 Aug, 15:41, Marnen Laibow-Koser [email protected] wrote:

Some people like to install through Ports or Fink or build it themselves
regardless, but I think that’s just a waste of time and disk space.

As long as the bug in bigdecimal doesn’t bother you :slight_smile:

Fred

On Aug 10, 11:28 am, Marnen Laibow-Koser [email protected] wrote:

Frederick C. wrote:

As long as the bug in bigdecimal doesn’t bother you :slight_smile:

Can’t say I’ve run into that. Info?

(For the record, the only projects on which I’ve been using BigDecimal
at all have been using Rubinius or JRuby, not MRI.)

I hadn’t either, but this article gives the details:
http://www.abletech.co.nz/2010/03/osx-10-6-3-installs-new-ruby-with-faulty-bigdecimal/

From the article:

BigDecimal.new(“3.0009”).to_f
=> 3.9

Nat

On 10 August 2010 08:39, Spong [email protected] wrote:

So ruby seems to be installed in two place: /usr/bin/ and /opt/local/
bin. The former is the ruby that came with my Mac, and the latter
from MacPorts. Should I not use MacPorts to install/update ruby?

Well, there’s nothing fundamentally wrong with having multiple Rubies
on one system. Before RVM [1] came along, I always used to compile my
own Ruby into /usr/local, and it seemed to live perfectly happy
alongside OS X’s built-in Ruby.

So, the fact that MacPorts’ Ruby is misbehaving in this way on your
system is strange. But unless you’re particularly interested in
fathoming that problem out, the quickest fix (as Marnen and Nat have
suggested) would be to uninstall MacPorts’ Ruby and use OS X’s
instead, or use RVM to install your Rubies.

Chris

Frederick C. wrote:

On 10 Aug, 15:41, Marnen Laibow-Koser [email protected] wrote:

Some people like to install through Ports or Fink or build it themselves
regardless, but I think that’s just a waste of time and disk space.

As long as the bug in bigdecimal doesn’t bother you :slight_smile:

Can’t say I’ve run into that. Info?

(For the record, the only projects on which I’ve been using BigDecimal
at all have been using Rubinius or JRuby, not MRI.)

Fred

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Nat B. wrote:

On Aug 10, 11:28�am, Marnen Laibow-Koser [email protected] wrote:

Frederick C. wrote:

As long as the bug in bigdecimal doesn’t bother you :slight_smile:

Can’t say I’ve run into that. �Info?

(For the record, the only projects on which I’ve been using BigDecimal
at all have been using Rubinius or JRuby, not MRI.)

I hadn’t either, but this article gives the details:
http://www.abletech.co.nz/2010/03/osx-10-6-3-installs-new-ruby-with-faulty-bigdecimal/

From the article:

BigDecimal.new(“3.0009”).to_f
=> 3.9

Ouch! I think I’m using patchlevel 287, which would imply that a later
upgrade to Snow Leopard fixed the patch, but I’m not at that computer
right now to check. If I am using the faulty version, that implies
that I finally have a use for RVM.

Nat

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]