Undefined method "sum"
leduyquang753 opened this issue · 1 comments
leduyquang753 commented
Hi! In my local TNoodle repository, when I ran ./tmt i18n check which uses the wca-i18n gem, the following error appeared:
leduyquang753@QuangPC:~/TNoodle$ ./tmt i18n check
['bundle', 'exec', 'wca_i18n', '--verbose', 'webscrambles/src/i18n/en.yml', 'webscrambles/src/i18n/vi.yml', 'webscrambles/src/i18n/en.yml']
bundle exec wca_i18n --verbose webscrambles/src/i18n/en.yml webscrambles/src/i18n/vi.yml webscrambles/src/i18n/en.yml
/var/lib/gems/2.3.0/gems/wca_i18n-0.4.1/exe/wca_i18n:39:in `block in compare_base_with_translations': undefined method `sum' for [0, 0, 0]:Array (NoMethodError)
from /var/lib/gems/2.3.0/gems/wca_i18n-0.4.1/exe/wca_i18n:37:in `each'
from /var/lib/gems/2.3.0/gems/wca_i18n-0.4.1/exe/wca_i18n:37:in `compare_base_with_translations'
from /var/lib/gems/2.3.0/gems/wca_i18n-0.4.1/exe/wca_i18n:26:in `main'
from /var/lib/gems/2.3.0/gems/wca_i18n-0.4.1/exe/wca_i18n:79:in `<top (required)>'
from /usr/local/bin/wca_i18n:23:in `load'
from /usr/local/bin/wca_i18n:23:in `<main>'
Hit excepthook! stderr.isatty: True stdin.isatty: True stdout.isatty: True
Traceback (most recent call last):
File "./tmt", line 1218, in <module>
tmt._main()
File "./tmt", line 231, in _main
self.args.func()
File "./tmt", line 303, in _i18n
runCmd(args, assertSuccess=True, showStatus=True)
File "./tmt", line 46, in runCmd
assert p.returncode == 0
AssertionError
> /home/leduyquang753/TNoodle/tmt(46)runCmd()
-> assert p.returncode == 0
(Pdb)
[1]+ Bị dừng ./tmt i18n check
What I was doing wrong???
jfly commented
Ah, it looks like Array#sum
was introduced in Ruby 2.4 and you are using Ruby 2.3. See https://blog.bigbinary.com/2016/11/02/ruby-2-4-introduces-enumerable-sum.html.
I've fixed this by changing the gem to require ruby >= 2.4. I'll update TNoodle to use the latest release of this gem.