Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] undefined method `deep_merge!' for {}:Concurrent::Hash #555

Open
jthorup84 opened this issue Feb 2, 2021 · 5 comments
Open

[BUG] undefined method `deep_merge!' for {}:Concurrent::Hash #555

jthorup84 opened this issue Feb 2, 2021 · 5 comments

Comments

@jthorup84
Copy link

What I tried to do

Tried to run specs after bundling on my rails 5 application.

What I expected to happen

Expected tests to run as they normally would

What actually happened

Ran into an error with the following stack trace:

NoMethodError:
  undefined method `deep_merge!' for {}:Concurrent::Hash
  Did you mean?  deep_merge
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n/backend/simple.rb:45:in `store_translations'
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n/backend/base.rb:230:in `block in load_file'
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n/backend/base.rb:230:in `load_file'
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n/backend/base.rb:18:in `block in load_translations'
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n/backend/base.rb:18:in `load_translations'
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n/backend/simple.rb:80:in `init_translations'
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n/backend/simple.rb:50:in `available_locales'
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n/config.rb:45:in `available_locales'
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n/config.rb:51:in `available_locales_set'
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n.rb:337:in `locale_available?'
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n.rb:343:in `enforce_available_locales!'
# /usr/local/bundle/gems/i18n-1.8.8/lib/i18n.rb:288:in `transliterate'
# /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/inflector/transliterate.rb:61:in `transliterate'
# /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/inflector/transliterate.rb:88:in `parameterize'
# /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/core_ext/string/inflections.rb:186:in `parameterize'

Versions of i18n, rails, and anything else you think is necessary

Rails 5 and up
Jruby 9.2
I18n 1.8.8

@radar
Copy link
Collaborator

radar commented Feb 2, 2021

I'm sorry for this trouble. I caused it in my attempts to fix #554. I am surprised that the tests didn't catch this mistake. I will investigate why.

radar added a commit that referenced this issue Feb 2, 2021
After #555, as this seems to be happening in 5.0.7

'https://github.com/rails/rails/blob/main/activesupport/activesupport.gemspec#L36' specifies that any i18n 1.x version will be used by this version of Rails.

We should be more careful.
@radar
Copy link
Collaborator

radar commented Feb 3, 2021

I am able to reproduce this:

Loading development environment (Rails 5.0.7.2)
irb(main):001:0> "thing".parameterize
Traceback (most recent call last):
       16: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/activesupport-5.0.7.2/lib/active_support/inflector/transliterate.rb:88:in `parameterize'
       15: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/activesupport-5.0.7.2/lib/active_support/inflector/transliterate.rb:61:in `transliterate'
       14: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n.rb:288:in `transliterate'
       13: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n.rb:343:in `enforce_available_locales!'
       12: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n.rb:337:in `locale_available?'
       11: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n/config.rb:51:in `available_locales_set'
       10: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n/config.rb:45:in `available_locales'
        9: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n/backend/simple.rb:50:in `available_locales'
        8: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n/backend/simple.rb:80:in `init_translations'
        7: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n/backend/base.rb:18:in `load_translations'
        6: from org/jruby/RubyArray.java:1809:in `each'
        5: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n/backend/base.rb:18:in `block in load_translations'
        4: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n/backend/base.rb:230:in `load_file'
        3: from org/jruby/RubyHash.java:1415:in `each'
        2: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n/backend/base.rb:230:in `block in load_file'
        1: from /Users/ryanbigg/.asdf/installs/ruby/jruby-9.2.14.0/lib/ruby/gems/shared/gems/i18n-1.8.8/lib/i18n/backend/simple.rb:45:in `store_translations'
NoMethodError (undefined method `deep_merge!' for {}:Concurrent::Hash)
Did you mean?  deep_merge

@radar
Copy link
Collaborator

radar commented Feb 3, 2021

I do not understand why this is happening. I can see that the method is listed as an instance method on Concurrent::Hash:

[2] pry(main)> Concurrent::Hash.instance_methods.sort.grep(/deep/)
=> [:deep_dup,
 :deep_merge,
 :deep_merge!,
 :deep_stringify_keys,
 :deep_stringify_keys!,
 :deep_symbolize_keys,
 :deep_symbolize_keys!,
 :deep_transform_keys,
 :deep_transform_keys!]

However:

[5] pry(main)> a = Concurrent::Hash.new
=> {}
[6] pry(main)> a.deep_merge!
NoMethodError: undefined method `deep_merge!' for {}:Concurrent::Hash

@radar
Copy link
Collaborator

radar commented Feb 3, 2021

NoMethodError: undefined method `deep_merge!' for {}:Concurrent::Hash
Did you mean?  deep_merge
from (pry):10:in `evaluate_ruby'
[14] pry(main)> a.deep_merge
NoMethodError: undefined method `deep_merge' for {}:Concurrent::Hash
Did you mean?  deep_merge!

@radar
Copy link
Collaborator

radar commented Feb 3, 2021

Okay, this seems very fresh and likely a bug in JRuby. jruby/jruby#6547

I'll park this issue for a few days and revise it towards the start of next week. In the interim, if you want your application to function correctly then I would recommend using i18n 1.8.7 for the moment.

mvz added a commit to mvz/factory_bot that referenced this issue Feb 21, 2021
composerinteralia pushed a commit to thoughtbot/factory_bot that referenced this issue Mar 30, 2021
* Remove obsolete gemfile

* Work around issue with the combination of I18n and JRuby

See jruby/jruby#6547 and
ruby-i18n/i18n#555

* Use correct released versions of activerecord-jdbcsqlite3-adapter

* Require CI to pass on JRuby again

* Build on latest JRuby 9.2 version
aledustet pushed a commit to thoughtbot/factory_bot that referenced this issue Apr 9, 2021
* Remove obsolete gemfile

* Work around issue with the combination of I18n and JRuby

See jruby/jruby#6547 and
ruby-i18n/i18n#555

* Use correct released versions of activerecord-jdbcsqlite3-adapter

* Require CI to pass on JRuby again

* Build on latest JRuby 9.2 version
connorchris831 pushed a commit to connorchris831/factory_bot that referenced this issue Dec 13, 2022
* Remove obsolete gemfile

* Work around issue with the combination of I18n and JRuby

See jruby/jruby#6547 and
ruby-i18n/i18n#555

* Use correct released versions of activerecord-jdbcsqlite3-adapter

* Require CI to pass on JRuby again

* Build on latest JRuby 9.2 version
SriHarshaxi pushed a commit to SriHarshaxi/factory_bot that referenced this issue Mar 17, 2023
* Remove obsolete gemfile

* Work around issue with the combination of I18n and JRuby

See jruby/jruby#6547 and
ruby-i18n/i18n#555

* Use correct released versions of activerecord-jdbcsqlite3-adapter

* Require CI to pass on JRuby again

* Build on latest JRuby 9.2 version
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

No branches or pull requests

2 participants