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

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 未定义的方法`run’for main:Object前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在部署时得到以下输出
  1. cap aborted!
  2. NoMethodError: undefined method `run' for main:Object
  3. config/deploy.rb:37:in `block (2 levels) in <top (required)>'
  4. /var/lib/gems/1.9.1/gems/capistrano-3.2.1/lib/capistrano/dsl/task_enhancements.rb:12:in `block in after'
  5. /var/lib/gems/1.9.1/gems/capistrano-3.2.1/lib/capistrano/application.rb:15:in `run'
  6. /var/lib/gems/1.9.1/gems/capistrano-3.2.1/bin/cap:3:in `<top (required)>'
  7. Tasks: TOP => deploy:permissions
  8. (See full trace by running task with --trace)
  9. The deploy has Failed with an error: #<NoMethodError: undefined method `run' for main:Object>

我正在使用Capistrano版本:3.2.1(Rake版本:10.3.2).
部署工作正常,但我创建了一个后部署任务来修改部署版本的所有者,这样看起来如此:

  1. namespace :deploy do
  2. task :permissions do
  3. run "chown -R :#{fetch(:group)} #{deploy_to} && chmod -R g+s #{deploy_to}"
  4. end
  5. end
  6.  
  7. after :deploy,"deploy:permissions"

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

解决方法

您的代码使用2.x语法,而您的版本是3.x.在3.x中,语法如下所示:
  1. namespace :deploy do
  2. on roles :all do
  3. execute :chown,"-R :#{fetch(:group)} #{deploy_to} && chmod -R g+s #{deploy_to}"
  4. end
  5. end

猜你在找的Ruby相关文章