为了使用带有 capistrano 的 erb 模板(无导轨),我遵循了https://github.com/faber-lotto/capistrano-template中给出的说明,但是在运行[bundle exec] cap staging define_usermacros -n --trace
capistrano 时告诉我该template
方法未知SSHKit::Backend::Printer
:
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke define_usermacros (first_time)
** Execute define_usermacros
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@10.33.66.12: undefined method `template' for #<SSHKit::Backend::Printer:0x007ff383bd4d80>
/usr/local/var/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute'
/usr/local/var/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
NoMethodError: undefined method `template' for #<SSHKit::Backend::Printer:0x007ff383bd4d80>
config/deploy.rb:42:in `block (2 levels) in <top (required)>'
/usr/local/var/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/usr/local/var/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/backends/abstract.rb:29:in `run'
/usr/local/var/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => define_usermacros
我尝试在捆绑包中升级和降级 capistrano、airbrush、sshkit,但无济于事,事情仍然失败。
目前 cap doctor 告诉我我正在使用以下版本:
环境
Ruby ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-darwin15]
Rubygems 2.6.10
Bundler 1.14.3
Command /usr/local/var/rbenv/versions/2.2.5/bin/cap staging doctor
宝石
capistrano 3.7.2 (update available)
airbrussh 1.2.0
rake 12.0.0
sshkit 1.13.1
net-ssh 4.1.0
capistrano-template 0.0.8
这是capistrano的东西:
宝石文件:
source "https://rubygems.org"
group :development do
gem "capistrano", "~> 3.7.0"
gem "capistrano-template"
end
帽文件:
require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require 'capistrano/capistrano_plugin_template'
配置/部署.rb:
[...]
desc 'Upload user macros as rendered erb-template'
task :define_usermacros do
on roles :all do
template 'resource.cfg', "#{release_path}/resource_file",
0o640,
locals: {
'user1' => 'blah'
}
end
end
...当然还有一个 erb 模板config/deploy/templates/shared/resource.cfg.erb
。
欢迎提供有关解决方案或如何调试问题的任何提示!