简体   繁体   English

Rake doc:rails 错误

[英]Rake doc:rails errors

Trying to generate Rails API documentation, but running into errors:尝试生成 Rails API 文档,但遇到错误:

$ rake doc:rails
rake aborted!
undefined method `task' for #<DummyApp::Application:0x00000100dd14d0>

(See full trace by running task with --trace)
MacBook-Pro-van-Joris-Ooms:dummy_app joris$ rake doc:rails --trace
rake aborted!
undefined method `task' for #<DummyApp::Application:0x000001023b1ea8>
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
/Users/joris/Desktop/Projects/Rails/dummy_app/Rakefile:7:in `<top (required)>'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.0/lib/rake/application.rb:78:in `block in load_rakefile'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.0/lib/rake/application.rb:61:in `block in run'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.0/lib/rake/application.rb:59:in `run'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.0/bin/rake:31:in `<top (required)>'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load'
/Users/joris/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>'

Had something similar earlier, where I had to downgrade my Rake (0.9) back to 0.8.7.之前有类似的情况,我不得不将我的 Rake (0.9) 降级回 0.8.7。 I upgraded my gems since though;不过,我升级了我的宝石; should I just downgrade again or is there a way to fix this and keep using Rake 0.9?我应该再次降级还是有办法解决这个问题并继续使用 Rake 0.9?

UPDATE :更新

After downgrading to Rake 0.8.7:降级到 Rake 0.8.7 后:

s$ rake doc:rails
(in /Users/joris/Desktop/Projects/Rails/dummy)
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:32: warning: already initialized constant RAKEVERSION
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake/alt_system.rb:32: warning: already initialized constant WINDOWS
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:404: warning: already initialized constant EMPTY_TASK_ARGS
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:452: warning: already initialized constant EMPTY
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:960: warning: already initialized constant RUBY_EXT
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:964: warning: already initialized constant RUBY
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:1033: warning: already initialized constant LN_SUPPORTED
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:1242: warning: already initialized constant ARRAY_METHODS
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:1245: warning: already initialized constant MUST_DEFINE
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:1249: warning: already initialized constant MUST_NOT_DEFINE
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:1253: warning: already initialized constant SPECIAL_RETURN
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:1259: warning: already initialized constant DELEGATING_METHODS
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:1569: warning: already initialized constant DEFAULT_IGNORE_PATTERNS
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:1575: warning: already initialized constant DEFAULT_IGNORE_PROCS
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:1612: warning: already initialized constant FileList
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:1638: warning: already initialized constant EARLY
/Users/joris/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.8.7/lib/rake.rb:1968: warning: already initialized constant DEFAULT_RAKEFILES
rake aborted!
stack level too deep

Using @Zabba's approach:使用@Zabba 的方法:

No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

after editing the Rakefile.编辑 Rakefile 后。

Thanks in advance!提前致谢!

Rake 0.9.0 has this problem. Rake 0.9.0 有这个问题。 To fix it, either downgrade to rake 0.8.7 or continue to use rake 0.9.0 and add the following just before the My_app_name::Application.load_tasks in Rakefile in the root of your app's directory:要修复它,请降级到 rake 0.8.7 或继续使用 rake 0.9.0 并在应用程序目录根目录的Rakefile中的My_app_name::Application.load_tasks之前添加以下内容:

#in case there is an error "undefined method `task'", add this (rake 0.9.0 has this bug)
module ::My_app_name
  class Application
    include Rake::DSL
  end
end

module ::RakeFileUtils
  extend Rake::FileUtilsExt
end

#code added above this line    
My_app_name::Application.load_tasks

Put this in your Gemfile and then use bundle exec rake instead:把它放在你的Gemfile中,然后使用bundle exec rake代替:

gem 'rake', '0.8.7'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM