我跑的时候
rails s
我收到了错误
[BUG] cross-thread violation on
rb_gc()
我找到了许多与此问题有关的链接.有one on StackOverflow,但它并没有真正给出答案.最有希望的答案是on the RVM site:
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 buggar down.
这是相当有用的,但我的Ruby-fu不够强大,无法知道哪些宝石有C扩展,哪些我应该尝试重新安装.关于该主题的其他几个链接似乎表明json gem有问题,所以我尝试按照建议的解决方案.
gem uninstall json gem install --platform=ruby
这对我来说并没有真正改变任何东西 – 在尝试启动Rails环境时我仍然得到完全相同的错误.
如何追踪此问题?
如果有帮助,这里是gem列表的输出:
actionmailer (3.2.2) actionpack (3.2.2) activemodel (3.2.2) activerecord (3.2.2) activeresource (3.2.2) activesupport (3.2.2) addressable (2.2.7) akami (1.0.0) arel (3.0.2) bcrypt-ruby (3.0.1) bson (1.6.1) bson_ext (1.6.1) builder (3.0.0) bundler (1.1.3,1.0.21) capybara (1.1.2) carmen (0.2.13) childprocess (0.3.1) ci_reporter (1.7.0) coderay (1.0.5) coffee-rails (3.2.2) coffee-script (2.2.0) coffee-script-source (1.2.0) commonjs (0.2.5) cucumber (1.1.9) cucumber-rails (1.3.0) database_cleaner (0.7.2) devise (2.0.4) diff-lcs (1.1.3) ejs (1.0.0) email_spec (1.2.1) engineyard (1.4.28) engineyard-serverside-adapter (1.6.3) erubis (2.7.0) escape (0.0.4) execjs (1.3.0) factory_girl (3.0.0) factory_girl_rails (3.0.0) faker (1.0.1) fakeweb (1.3.0) ffi (1.0.11) gherkin (2.9.3) gyoku (0.4.4) haml (3.1.4) haml-rails (0.3.4) hash-deep-merge (0.1.1) highline (1.6.11) hike (1.2.1) httpi (0.9.6) i18n (0.6.0) jasmine (1.1.2) jasmine-core (1.1.0) jasminerice (0.0.8) journey (1.0.3) jquery-rails (2.0.1) json (1.6.6) json_pure (1.6.6) kaminari (0.13.0) kgio (2.7.4) launchy (2.0.5) less (2.1.0) less-rails (2.2.0) libv8 (3.3.10.4 x86_64-darwin-11) log4r (1.1.10) mail (2.4.4) Metaclass (0.0.1) method_source (0.7.1) mime-types (1.18) mocha (0.10.5) mongo (1.6.1) mongoid (2.4.7) mongoid-rspec (1.4.4) multi_json (1.2.0) net-ssh (2.2.2) newrelic_rpm (3.3.3) nokogiri (1.5.2) nori (1.1.0) open4 (1.3.0) orm_adapter (0.0.7) polyglot (0.3.3) pr_geohash (1.0.0) pry (0.9.8.4) pry-highlight (0.0.1) pry_debug (0.0.1) rack (1.4.1) rack-cache (1.2) rack-ssl (1.3.2) rack-test (0.6.1) rails (3.2.2) rails-footnotes (3.7.6) railties (3.2.2) raindrops (0.8.0) rake (0.9.2.2) rdoc (3.12) recursive-open-struct (0.2.1) rest-client (1.6.7) rpm_contrib (2.1.8) rsolr (1.0.7) rspec (2.9.0) rspec-core (2.9.0) rspec-expectations (2.9.0) rspec-mocks (2.9.0) rspec-rails (2.9.0) rubyzip (0.9.6.1) sass (3.1.15) sass-rails (3.2.5) savon (0.9.9) selenium-webdriver (2.20.0) settings-tree (0.2.1) simplecov (0.6.1) simplecov-html (0.5.3) simplecov-rcov (0.2.3) slop (2.4.4) spine-rails (0.1.0) spork (1.0.0rc2) sprockets (2.1.2) sunspot (1.3.1) sunspot_mongoid (0.4.1) sunspot_rails (1.3.1) sunspot_solr (1.3.1) term-ansicolor (1.0.7) therubyracer (0.10.1) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) twitter-bootstrap-rails (2.0.6) tzinfo (0.3.32) uglifier (1.2.4) unicorn (4.2.1) warden (1.1.1) wasabi (2.1.0) xpath (0.1.4)
解决方法
清理
要清理旧版本的宝石:
gem cleanup --dryrun
JSON
要暂时查看json gem是否存在问题,请从json(native)切换到json(pure ruby)并更改你的Gemfile:
gem install json_pure
本土宝石
你的宝石列表有一些突然出现给我作为本机:
> bcrypt
> bson
> erubis
> ffi(启用大量本机连接)
>小黄瓜
> kgio
>少
> nokogiri
>雨滴
> therubyracer(许多不可预知的问题恕我直言)
>独角兽
FFI
你的宝石ffi特别有趣 – 你碰巧知道你在做什么吗?
ffi使Ruby代码能够调用本机代码,例如,如果Ruby应用程序的某些部分需要连接到本机库.
当你诊断出你的问题时,我会先看看这个宝石.
要查找具有Makefile文件的任何宝石,这是一个很好的指示,它们具有本机代码:
find / | grep "/ruby/gems/" | grep Makefile
要查找所有宝石,您可以删除它们:
find / | grep "/ruby/gems/"
核武RVM
要核实RVM或它的碎片,你可以使用rvm uninstall,rvm implode或这个核心RVM并查找任何挥之不去的部分的脚本:
https://raw.github.com/SixArm/sixarm_unix_shell_scripts/master/rvm-uninstall-danger
尝试rbenv bundler
我从使用rvm改为使用rbenv bundler,它对我很有用.
rbenv工具是rvm管理Ruby版本的直接竞争对手:
https://github.com/sstephenson/rbenv
Bundler是管理gemsets和gem依赖项的好方法:
http://gembundler.com/
酿造
如果您使用的是Mac并使用MacPorts,请更改为Homebrew: