ruby-i18n / i18n

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

Frozen Hashes with Psych 3.3.2+/4.0 from YAML #676

Open broksonic21 opened 1 year ago

broksonic21 commented 1 year ago

Following up on https://github.com/ruby-i18n/i18n/issues/648

This change happens whenever psych 3.3.2+ (or 4.0/5.0) is loaded, either as a gem, or as part of default gems for Ruby 3.1/Rails 7.1 (or irb 1.8.0 which brought in a new psych via https://github.com/ruby/irb/issues/703, though they are reverting that part ).

Previous ruby's (3.0/2.7.8/etc) had earlier versions of psych as a Default gem so folks wouldn't have run into this unless they intentionally loaded a new psych version.

The change in psych is: https://github.com/ruby/psych/commit/cb50aa8d3fb8be01897becff77b4922b12a0ab4c

This is because unsafe_load_files now exists so the hash is now frozen by i18n.

https://github.com/ruby-i18n/i18n/blob/32c957e413f8493ccffa66e1ecce8e47e3c9153c/lib/i18n/backend/base.rb#L248-L250

There's a few scenarios this can break, but as an example, one backend this breaks is https://github.com/annkissam/i18n-recursive-lookup (which admittedly, is pretty old)

due to https://github.com/annkissam/i18n-recursive-lookup/blob/766750f845a4e0509b62fdc6d1be3137be8d1421/lib/i18n/backend/recursive_lookup.rb#L50

which tries to recursively update the backend.

so 2 questions:

radar commented 12 months ago

Related to #658.