undefined method `run' for main:Object

感情迁移 提交于 2019-12-22 01:38:11

问题


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:

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.


回答1:


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

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


来源:https://stackoverflow.com/questions/23850404/undefined-method-run-for-mainobject

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!