尝试生成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>'
之前有过类似的东西,我不得不将我的佣金(0.9)降级回0.8.7。虽然我升级了我的宝石;我应该再次降级还是有办法解决这个问题并继续使用Rake 0.9?
更新:
降级为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
使用@ Zabba的方法:
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
编辑Rakefile后。
提前致谢!
答案 0 :(得分:2)
Rake 0.9.0有这个问题。
要修复它,要么降级到rake 0.8.7或继续使用rake 0.9.0并在应用程序目录根目录中My_app_name::Application.load_tasks
的{{1}}之前添加以下内容:
Rakefile
答案 1 :(得分:1)
将其放在Gemfile
中,然后改为使用bundle exec rake
:
gem 'rake', '0.8.7'