无法构建简单的rake任务

时间:2015-07-31 04:19:20

标签: ruby-on-rails ruby rake

我使用代码

创建了一个任务lib/tasks/initiate.rake
namespace :initiate do
  desc "initiate bundle install"
  task :initiate do
    `bundle install`
  end
end

我不断收到以下回复:

$ rake initiate
warning: parser/current is loading parser/ruby22, which recognizes
warning: 2.2.3-compliant syntax, but you are running 2.2.1.
rake aborted!
Don't know how to build task 'initiate'

(See full trace by running task with --trace)

发生了什么?

2 个答案:

答案 0 :(得分:2)

您必须使用rake <namespace>:<task>

在您的情况下,rake initiate:initiate

答案 1 :(得分:0)

你可以运行:

rake -T | grep initiate

要找出正确的命名空间和名称,您应该使用它来运行该任务。