2014-05-24 76 views
14

部署時我得到以下輸出:未定義的方法`用於主運行」:對象

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> 

我使用Capistrano的版本:3.2.1(瑞克版本:10.3.2)。 部署工作正常,但我創建了一個部署後的任務修改部署的版本看起來如此的所有者:

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" 

瓦爾正確定義(我固定在這之前的錯誤),但我得到這個缺少的方法錯誤運行方法,我不知道爲什麼。

+1

它通過調用'on'來指定我想要運行代碼的位置。我也必須用execute命令替換run命令。 – agro

回答

18

你的代碼使用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 
+0

我想我混合了一些不同的帽子版本。 它現在的作品,所以thx! – agro

+0

@Gergo Erdosi:什麼是可以的'命名空間中的等價物:MYAPP做 任務:restart_webserver做 #重新啓動Web服務器 運行 「命令服務的Apache2重啓」 結束 結束後 「部署」, 「MYAPP:restart_webserver」' –

相關問題