OSX, RubyGems and cross-thread violations in rb_gc

I recently decided to migrate away from OSX’s default ruby install yesterday and noticed a few quirky hangups. Firstly, for some reason, and I’m not sure if it is just me or not, OSX’s default $PATH variable is putting /usr/local/bin AFTER /bin making your local installs not enabled by default. (Editing the /etc/paths didn’t do the trick so I manually added it to PATH).

The installation went easily for both ruby gems and ruby, but I decided to take a ’short cut’ and copy all my gems from /Library/Ruby/Gems into my /usr/local/lib directory which started raising all kinds of errors — this one, in particular was obnoxious.

[BUG] cross-thread violation on rb_gc()

Luckily, all that means is that I copied over gems which were compiled against the standard OSX ruby version and not the new one. This was a little script I wrote which will show you which gems need to be re-compiled. Just cd over to your /usr/local/lib/ruby/gems/1.8/gems directory and run:

gems $>ls -1 **/**/*.bundle|ruby -pe '$_.gsub! /\-.*/, ""'|uniq

to get a list, or pipe that into $> sudo gem install and that should clear up those gc issues.



Comments

  1. Lance June 1st

    Comment Arrow

    thanks man, this really helped me out.

    Cheers


  2. shyam July 13th

    Comment Arrow

    I get following errors while going through your insrtuction:
    gems $ ls -1 **/**/*.bundle|ruby -pe ‘$_.gsub! /\-.*/, “”‘|uniq
    -e:1: Invalid char `\342′ in expression
    -e:1: Invalid char `\200′ in expression
    -e:1: Invalid char `\230′ in expression
    -e:1: syntax error, unexpected ‘.’
    ‘.gsub!
    ^
    Please suggest me


  3. Rolf Bjaanes July 31st

    Comment Arrow

    try this instead to find all the gems:

    ruby -rubygems -e ‘p Gem.source_index.find_all { |n,s| !s.extensions.empty? }.map { |n,s| [s.name, s.version.to_s] }’


  4. Xavier Shay August 4th

    Comment Arrow

    to pipe it you need xargs:

    ls -1 **/**/*.bundle|ruby -pe ‘$_.gsub! /\-.*/, “”‘|uniq | xargs sudo gem install

    if you’re in a rush, you can speed it up a bit by passing –no-rdoc and –no-ri options to gem install.


Add Yours

  • Author Avatar

    YOU


Comment Arrow



About Author

Rob Hurring

Ruby, Rails, PHP, bash... oh my!