rake db:migrate error不知道如何构建任务'rails_env'

时间:2012-09-18 16:58:51

标签: ruby-on-rails-3 rake rake-task

运行rake db:migrate时出错。我最近添加了一个gem gcm_on_rails,之后我才收到错误。

 rake aborted!
 Don't know how to build task 'rails_env'

 Tasks: TOP => db:migrate => db:load_config

请帮忙

   rake aborted!
   Don't know how to build task 'rails_env'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task_manager.rb:49:in `[]'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:60:in `lookup_prerequisite'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:56:in `block in prerequisite_tasks'
   /Users/test/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:56:in `collect'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:56:in `prerequisite_tasks'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
  /Users/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
  /Users/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
   /Users/test/.rvm/gems/ruby-1.9.2-p320@global/bin/rake:19:in `load'
   /Users/test/.rvm/gems/ruby-1.9.2-p320@global/bin/rake:19:in `<main>'
   Tasks: TOP => db:migrate => db:load_config

1 个答案:

答案 0 :(得分:0)

为了使用gem中指定的rake任务,我在应用程序控制器中添加了以下代码。这导致了这个问题。 当我删除它时,它的工作正常。

require 'rake'
Rake::Task.clear
MyAPP::Application.load_tasks