The issue has to do with how keyword arguments are handled in ruby 3.0 and how ice_cube is passing its arguments to I18n.localize.
So, extracting and simplifying the buggy code, this worked on ruby < 3
RUBY_VERSION # "2.7.2"
def foo(*args)
bar(*args)
end
def bar(object, locale: nil, format: nil, **options)
puts "object:#{object}"
puts "locale:#{locale}"
puts "format:#{format}"
puts "options:#{options}"
end
foo('date', format: 'whatever')
# object:date
# locale:
# format:whatever
# options:{}
And from ruby >= 3
RUBY_VERSION # "3.0.0"
def foo(*args)
bar(*args)
end
def bar(object, locale: nil, format: nil, **options)
puts "object:#{object}"
puts "locale:#{locale}"
puts "format:#{format}"
puts "options:#{options}"
end
foo('date', format: 'whatever')
# Traceback (most recent call last):
# 16: from /Users/alter/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli.rb:24:in `start'
# 15: from /Users/alter/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
# 14: from /Users/alter/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli.rb:30:in `dispatch'
# 13: from /Users/alter/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
# 12: from /Users/alter/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
# 11: from /Users/alter/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
# 10: from /Users/alter/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli.rb:497:in `exec'
# 9: from /Users/alter/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli/exec.rb:28:in `run'
# 8: from /Users/alter/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli/exec.rb:63:in `kernel_load'
# 7: from /Users/alter/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli/exec.rb:63:in `load'
# 6: from /Users/alter/.rbenv/versions/3.0.0/bin/irb:23:in `<top (required)>'
# 5: from /Users/alter/.rbenv/versions/3.0.0/bin/irb:23:in `load'
# 4: from /Users/alter/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/irb-1.3.0/exe/irb:11:in `<top (required)>'
# 3: from (irb):11:in `<main>'
# 2: from (irb):3:in `foo'
# 1: from (irb):5:in `bar'
# ArgumentError (wrong number of arguments (given 2, expected 1))
So, the fix I can see is to explicitely passing the parameters to the method:
def foo2(object, **options)
bar(object, **options)
end
foo2('date', format: 'whatever')
# object:date
# locale:
# format:whatever
# options:{}
Or in terms of the involved module:
module IceCube
module I18n
def self.l(object, **options)
backend.l(object, **options)
end
end
end
and send a PR, use your own fork, monkey-patch, whatever works best for you.
But most important, brace yourself to find this issue in a lot of other gems, as the first stable ruby 3 version was just released 2 days ago, so probably you'll have these type of issues with other gems, specially the unmaintained ones.
Good luck.
Update
Looking your PR I didn't remember part of the code that you modified it, then I realized I was focused on 0.16.3 version, which it was the one you mentioned in the question. Things are, master branch has a lot more changes than the last 0.16.3 version, specially this change where is delegating the locale/translate methods to the backend that, at the end of the day, is a better solution than mine, and it should fix your issue.
So, in your Gemfile
gem 'ice_cube', git: 'https://github.com/seejohnrun/ice_cube.git', branch: :master
should do the trick. Anyway I'll left my previous response as reference for anyone having the issue in general terms and not specifically with ice_cube.