From 8038bb2f96250e4c13fb6ced187482f3bb2c4972 Mon Sep 17 00:00:00 2001 From: k0kubun Date: Thu, 22 Feb 2018 15:03:08 +0000 Subject: [PATCH] tool/generic_erb.rb: check ERB version instead of Ruby's. When older ERB is installed but Ruby is still 2.6.0, this may cause error like: ``` Traceback (most recent call last): 5: from ../src/tool/generic_erb.rb:36:in `
' 4: from ../src/tool/generic_erb.rb:36:in `map' 3: from ../src/tool/generic_erb.rb:43:in `block in
' 2: from ../src/tool/generic_erb.rb:43:in `block (2 levels) in
' 1: from /opt/local/lib/ruby/2.6.0/erb.rb:873:in `result' /opt/local/lib/ruby/2.6.0/erb.rb:869:in `block in result': no implicit conversion of Hash into Integer (TypeError) ``` For safety, I changed this to check ERB's version. See also: r62529. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/generic_erb.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tool/generic_erb.rb b/tool/generic_erb.rb index 83c569b55b..42555ef0a0 100644 --- a/tool/generic_erb.rb +++ b/tool/generic_erb.rb @@ -34,7 +34,8 @@ unchanged = color.pass("unchanged") updated = color.fail("updated") result = templates.map do |template| - if RUBY_VERSION >= '2.6' + match = ERB.version.match(/\Aerb\.rb \[(?[^ ]+) /) + if match && match[:version] >= '2.2.0' # Ruby 2.6+ erb = ERB.new(File.read(template), trim_mode: '%-') else erb = ERB.new(File.read(template), nil, '%-')