ruby-i18n / i18n

Internationalization (i18n) library for Ruby
MIT License
977 stars 408 forks source link

[BUG] i18n 1.9.0 LoadError: cannot load such file -- i18n/core_ext/hash #603

Closed olleolleolle closed 2 years ago

olleolleolle commented 2 years ago

What I tried to do

See the CI run.

LoadError: cannot load such file -- i18n/core_ext/hash

What I expected to happen

Passing tests.

What actually happened

An error in requires. https://github.com/ruby-i18n/i18n/search?q=core_ext shows that i18n/core_ext/hash is still being required, but is probably removed?

``` /opt/hostedtoolcache/Ruby/3.0.3/x64/bin/ruby -w -I"lib:lib:test" /home/runner/work/i18n/i18n/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb "test/api/all_features_test.rb" "test/api/cascade_test.rb" "test/api/chain_test.rb" "test/api/fallbacks_test.rb" "test/api/key_value_test.rb" "test/api/memoize_test.rb" "test/api/override_test.rb" "test/api/pluralization_test.rb" "test/api/simple_test.rb" "test/backend/cache_file_test.rb" "test/backend/cache_test.rb" "test/backend/cascade_test.rb" "test/backend/chain_test.rb" "test/backend/exceptions_test.rb" "test/backend/fallbacks_test.rb" "test/backend/interpolation_compiler_test.rb" "test/backend/key_value_test.rb" "test/backend/memoize_test.rb" "test/backend/metadata_test.rb" "test/backend/pluralization_fallback_test.rb" "test/backend/pluralization_scope_test.rb" "test/backend/pluralization_test.rb" "test/backend/simple_test.rb" "test/backend/transliterator_test.rb" "test/gettext/api_test.rb" "test/gettext/backend_test.rb" "test/i18n/exceptions_test.rb" "test/i18n/gettext_plural_keys_test.rb" "test/i18n/interpolate_test.rb" "test/i18n/load_path_test.rb" "test/i18n/middleware_test.rb" "test/i18n_test.rb" "test/locale/fallbacks_test.rb" "test/locale/tag/rfc4646_test.rb" "test/locale/tag/simple_test.rb" "test/utils_test.rb" test_declarative is deprecated for Minitest::Unit::TestCase test_declarative is deprecated for Minitest::Test /home/runner/work/i18n/i18n/test/backend/cache_test.rb:65: warning: assigned but unused variable - cache_key Skipping cache tests using ActiveSupport /home/runner/work/i18n/i18n/lib/i18n/backend/chain.rb:3:in `require': cannot load such file -- i18n/core_ext/hash (LoadError) from /home/runner/work/i18n/i18n/lib/i18n/backend/chain.rb:3:in `' from /home/runner/work/i18n/i18n/test/backend/chain_test.rb:2:in `require' from /home/runner/work/i18n/i18n/test/backend/chain_test.rb:2:in `' from /home/runner/work/i18n/i18n/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `require' from /home/runner/work/i18n/i18n/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `block in
' from /home/runner/work/i18n/i18n/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `select' from /home/runner/work/i18n/i18n/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `
' not testing with Cache enabled because active_support can not be found ```

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

Affected: v1.9.0, which was just released.

Update: #602 makes CI green again.

Workaround is simple: in the Gemfile, avoid installing latest release.

gem "i18n", "< 1.9.0"

See the CI output.

In addition, radar just did a greatly reduced the outstanding triage work on this repository. Kudos!

schinery commented 2 years ago

Looks like there is a PR to revert the breaking change - https://github.com/ruby-i18n/i18n/issues/603

olleolleolle commented 2 years ago

Right, #602 is the Pull Request.

schinery commented 2 years ago

Meant #602 (not yet had coffee) 🤦🏻‍♂️

mpantel commented 2 years ago

Actually this https://github.com/ruby-i18n/i18n/pull/573#issuecomment-1023621489 might be the problem cause...

radar commented 2 years ago

I am sorry for stuffing this one up. Clearly #602 should've been merged and I should've looked at the right GH actions build, not the one before the latest.

I've yanked 1.9.0, and have now pushed 1.9.1.

pboling commented 2 years ago

For anyone using tools that give this error (e.g. chewy v5)

LoadError: cannot load such file -- i18n/core_ext/hash

A potential fix is to create a file relative to a load path of the project (which may require forking it) at i18n/core_ext/hash.rb and then have a single line in the file:

require 'active_support/core_ext/hash/keys'

... which will also require adding activesupport as a dependency, if it wasn't already.

See: https://github.com/toptal/chewy/pull/834