加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 未定义的方法`run’for main:Object

发布时间:2020-12-16 20:28:03 所属栏目:百科 来源:网络整理
导读:我在部署时得到以下输出: cap aborted!NoMethodError: undefined method `run' for main:Objectconfig/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 `b
我在部署时得到以下输出:
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(Rake版本: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"

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

解决方法

您的代码使用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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读