Skip to content

Commit

Permalink
Fix ci on Ruby 2.5
Browse files Browse the repository at this point in the history
Fix an issue where the argument passing method for ERB.new in Ruby 2.5 differs from Ruby 2.6 and above, causing errors during template generation.

```
SSHKit::Runner::ExecuteError: Exception while executing as willnet@localhost: no implicit conversion of Hash into Integer
```

ref: https://ruby-doc.org/stdlib-2.5.0/libdoc/erb/rdoc/ERB.html#method-c-new
  • Loading branch information
willnet committed Jul 9, 2024
1 parent 24029e9 commit b53f608
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/capistrano/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def compiled_template_puma(from, role)
File.expand_path("../templates/#{from}.rb.erb", __FILE__)
].detect { |path| File.file?(path) }
erb = File.read(file)
StringIO.new(ERB.new(erb, trim_mode: '-').result(binding))
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.6')
StringIO.new(ERB.new(erb, nil, '-').result(binding))
else
StringIO.new(ERB.new(erb, trim_mode: '-').result(binding))
end
end

def template_puma(from, to, role)
Expand Down

0 comments on commit b53f608

Please sign in to comment.