为什么我不能在我的任务中使用 Capistrano 的信息方法?

Why can't I use Capistrano's info method in my task?

我想使用 info 在覆盖的 Capistrano 任务中输出一些内容,就像 capistrano-rails 所做的那样(例如 here)。

但是有了这个任务:

namespace :deploy do

  if ENV['DB_MIGRATE'] == 'skip'
    Rake::Task['deploy:migrate'].clear_actions

    desc "Override Capistrano's default behavior, do not migrate on deploy"
    task :migrate do
      info '[deploy:migrate] Skipping migrations due to DB_MIGRATE=skip'
    end
  end

end

我收到这个错误:

$ DB_MIGRATE=skip bundle exec cap staging deploy:migrate
(Backtrace restricted to imported tasks)
cap aborted!
NoMethodError: undefined method `info' for main:Object

Tasks: TOP => deploy:migrate
(See full trace by running task with --trace)

我需要做什么才能在自己的任务中使用 info

Capistrano 在 on 块中公开 info 方法

http://capistranorb.com/2013/06/01/release-announcement.html

Capistrano exposes the methods debug(), info(), warn(), error() and fatal() inside of on() blocks which can be used to log using the existing logging infrastructure and streaming IO formatters: