1

I am trying to upgrade my app from rails 3.2.18 to rails 4.0 and I'm stuck on an issue with rake.

I have a custom doc.rake task that overrides doc:app with the following code inside that worked fine on rails 3:

  # Replace Rails' rake doc:app with ours, which uses yardoc
  Rake::Task["doc:app"].clear.enhance do
    # Uses .yardopts_app file in rails root
    app_dir = 'doc/generated/app'
    sh "rm -rf #{app_dir}"
    sh "bundle exec yardoc --plugin rails --yardopts .yardopts_app"
    app_doc_files_dir = "#{app_dir}/doc-files"
    Dir.mkdir( app_doc_files_dir )
    cp_r( 'doc/files/app/doc-files/.', app_doc_files_dir )
  end

Since upgrading rails, any rake task I try to run fails with the error:

rake aborted!
Don't know how to build task 'doc:app'

I'm really at a loss as to why this is happening. I can't find any reference to rails 4 removing the default doc:app task, so it should still exist for me to overwrite.

CoolTapes
  • 417
  • 5
  • 14
  • I have the same problem. What is odd is that it is not reproducible on every machine. My dev machine works fine, however I run into that error on a staging server. Both running ruby 2.1.1p76 and rails 4.1. – agios May 28 '14 at 23:01

1 Answers1

2

I was able to solve this by adding

require 'rails/tasks'

to the top of my rake file. So my full rake file looks like this now:

require 'rdoc/task'
require 'rails/tasks'

Rake::Task["doc:app"].clear

namespace :doc do
  RDoc::Task.new('app') do |rdoc|
    ...
  end
end
Kelsin
  • 823
  • 7
  • 7