main:Object的未定义方法`run'

时间:2022-03-17 23:54:59

i'm getting the following output when deploying:

部署时我得到以下输出:

cap aborted!
NoMethodError: undefined method `run' for main:Object
config/deploy.rb:37:in `block (2 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/capistrano-3.2.1/lib/capistrano/dsl/task_enhancements.rb:12:in `block in after'
/var/lib/gems/1.9.1/gems/capistrano-3.2.1/lib/capistrano/application.rb:15:in `run'
/var/lib/gems/1.9.1/gems/capistrano-3.2.1/bin/cap:3:in `<top (required)>'
Tasks: TOP => deploy:permissions
(See full trace by running task with --trace)
The deploy has failed with an error: #<NoMethodError: undefined method `run' for main:Object>

i'm using Capistrano Version: 3.2.1 (Rake Version: 10.3.2). the deploy works fine but i created a after deploy task to modify the owner of the deployed release which looks so:

我正在使用Capistrano版本:3.2.1(耙子版本:10.3.2)。部署工作正常,但我创建了一个After deploy任务来修改部署版本的所有者,看起来如此:

namespace :deploy do
    task :permissions do
      run "chown -R :#{fetch(:group)} #{deploy_to} && chmod -R g+s #{deploy_to}"
    end
end

after :deploy, "deploy:permissions"

vars are defined correctly (i fixed that error before) but i get this missing method error for the run method and i dont know why.

vars是正确定义的(我之前修复了那个错误)但是我得到了这个缺少方法错误的run方法,我不知道为什么。

1 个解决方案

#1


20  

Your code uses 2.x syntax, while your version is 3.x. In 3.x, the syntax looks like this:

您的代码使用2.x语法,而您的版本是3.x.在3.x中,语法如下所示:

namespace :deploy do
  on roles :all do
    execute :chown, "-R :#{fetch(:group)} #{deploy_to} && chmod -R g+s #{deploy_to}"
  end
end

#1


20  

Your code uses 2.x syntax, while your version is 3.x. In 3.x, the syntax looks like this:

您的代码使用2.x语法,而您的版本是3.x.在3.x中,语法如下所示:

namespace :deploy do
  on roles :all do
    execute :chown, "-R :#{fetch(:group)} #{deploy_to} && chmod -R g+s #{deploy_to}"
  end
end