Ruby RI失败了RDoc :: Context :: Section的实例需要有方法`marshal_load'(TypeError)

时间:2013-08-21 11:56:03

标签: ruby-on-rails ruby bundler rdoc ri

我在OSX上的 Ruby 2.0.0(rvm)下运行 Rails 3.2.14 。当我尝试访问大多数方法的ri文档时,我得到以下堆栈跟踪。

堆栈跟踪:

/Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/store.rb:196:in `load': instance of RDoc::Context::Section needs to have method `marshal_load' (TypeError)
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/store.rb:196:in `block in load_class'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/store.rb:195:in `open'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/store.rb:195:in `load_class'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:609:in `block in classes_and_includes_for'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:607:in `map'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:607:in `classes_and_includes_for'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:681:in `display_class'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:712:in `display_name'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:739:in `block in display_names'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:736:in `each'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:736:in `display_names'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:1137:in `run'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/lib/rdoc/ri/driver.rb:320:in `run'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/gems/rdoc-3.12.2/bin/ri:12:in `<top (required)>'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/bin/ri:23:in `load'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/bin/ri:23:in `<main>'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/daryl/.rvm/gems/ruby-2.0.0-p195@deals/bin/ruby_noexec_wrapper:14:in `<main>'

我认为问题与Ruby 2默认为 RDoc 4.0 有关,而捆绑环境由于依赖性而使用 RDoc 3.12.2

journey-1.0.4 depends on rdoc (~> 3.11, development)
journey-1.0.4 depends on rdoc (~> 3.10, development)
tilt-1.4.1 depends on rdoc (>= 0, development)
tilt-1.4.1 depends on rdoc (>= 0, development)
mail-2.5.4 depends on rdoc (>= 0, development)
rdoc-3.12.2 depends on rdoc (~> 3.10, development)
railties-3.2.14 depends on rdoc (~> 3.4)
kaminari-0.14.1 depends on rdoc (>= 0, development)
arel-3.0.2 depends on rdoc (~> 3.10, development)
nokogiri-1.6.0 depends on rdoc (~> 3.10, development)
launchy-2.3.0 depends on rdoc (~> 3.12, development)
oauth2-0.8.1 depends on rdoc (>= 0, development)
sqlite3-1.3.7 depends on rdoc (~> 3.10, development)
uglifier-2.1.1 depends on rdoc (>= 3.11, development)

我的猜测是,当gem生成ri文档时,它正在使用 rdoc 4.0.0 但是 3.12.2 正在使用它来尝试读取它。我在Rails项目的上下文之外访问文档没有问题。

有什么建议吗?我猜这可能不再是 Rails 4 中的一个问题,但目前这不是一个真正的选择。

非常感谢!

2 个答案:

答案 0 :(得分:1)

我最终咬了一口子并升级到 Rails 4 ,这完全解决了这个问题。 Rails 4 Ruby 2.0.0 的gem依赖关系排成一行。

对于任何有兴趣使用RI但没有选择升级到 Rails 4 的人,我建议坚持使用 Ruby 1.9.3 ;这包括 RDoc 3.12.2 ,它与上述 Rails 3.2.14 依赖项兼容。

答案 1 :(得分:1)

这可能意味着您缺少rdoc gem的[正确版本]。试试gem install rdoc