Skip to content

Conversation

@taketo1113
Copy link
Contributor

Background

A SyntaxError (syntax error, unexpected keyword_rescue, expecting keyword_end) occurs in the ipaddr gem's CI when running tests with Ruby 2.4:

Run bundle exec rake test
...
/home/runner/work/ipaddr/ipaddr/vendor/bundle/ruby/2.4.0/gems/test-unit-ruby-core-1.0.9/lib/core_assertions.rb:75:in `require_relative': /home/runner/work/ipaddr/ipaddr/vendor/bundle/ruby/2.4.0/gems/test-unit-ruby-core-1.0.9/lib/envutil.rb:108: syntax error, unexpected keyword_rescue, expecting keyword_end (SyntaxError)
      rescue Timeout::Error
            ^
/home/runner/work/ipaddr/ipaddr/vendor/bundle/ruby/2.4.0/gems/test-unit-ruby-core-1.0.9/lib/envutil.rb:481: syntax error, unexpected keyword_end, expecting end-of-input
...

https://github.com/ruby/ipaddr/actions/runs/18297568280/job/52098942424?pr=88#step:4:16

This error occurs only with the combination of Ruby 2.4 and test-unit-ruby-core 1.0.9.
It does not occur on Ruby 2.5 or later.

Details

In Ruby 2.4 and earlier, rescue cannot be used without an explicit begin/end block.
Therefore, this Pull Request adds the missing begin and end to fix the syntax error.

@hsbt
Copy link
Member

hsbt commented Oct 8, 2025

Thanks always ❤️

@taketo1113 taketo1113 deleted the fix-syntax-error-ruby-2.4 branch October 8, 2025 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants