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

Incompatibility with Psych 4.0 #2330

Closed
tadman opened this issue May 27, 2021 · 4 comments · Fixed by #2413
Closed

Incompatibility with Psych 4.0 #2330

tadman opened this issue May 27, 2021 · 4 comments · Fixed by #2413

Comments

@tadman
Copy link

tadman commented May 27, 2021

Describe the bug

Incompatibility with Psych 4.0.0 and the new YAML defaults.

To Reproduce

This Gemfile:

source 'https://rubygems.org/'

gem 'psych', '~> 4.0.0'
gem 'faker'

And this code:

require 'faker'

puts Faker::Lorem.paragraphs

Expected behavior

Should be printing something fake.

Additional context

Generates an exception, as alias resolution is disabled by default in Psych 4.0

/.../gems/i18n-1.8.10/lib/i18n/backend/base.rb:245:in `rescue in load_yml': can not load translations from /.../gems/faker-2.18.0/lib/locales/en-SG.yml: #<Psych::BadAlias: Unknown alias: male_first_name> (I18n::InvalidLocaleData)
@tadman tadman changed the title Issue title goes here Incompatibility with Psych 4.0 May 27, 2021
@tadman
Copy link
Author

tadman commented May 27, 2021

This can be "fixed" temporarily by pinning to gem 'psych', '3.3.2' but that's not ideal.

koic added a commit to koic/i18n that referenced this issue May 28, 2021
This PR fixes the following build error when using Psych 4.0.

```console
% ruby -v
ruby 3.1.0dev (2021-05-17T10:51:51Z master ee611341c9) [x86_64-darwin19]

% cd path/to/i18n

% bundle exec rake
(snip)

Finished in 1.310478s, 1265.1872 runs/s, 2004.6121 assertions/s.

  1) Error:
KeyValueCacheFileTest#test_load_translations_caches_file_through_updated_modification_time:
I18n::InvalidLocaleData: can not load translations from
/var/folders/6j/5l8q3y250b97529_tcssrwlm0000gn/T/test20210528-81604-ijnu7v.yml:
#<Psych::DisallowedClass: Tried to load unspecified class: Symbol>
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:245:in
    `rescue in load_yml'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:241:in
    `load_yml'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:226:in
    `load_file'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/cache_file.rb:23:in
    `load_file'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:18:in
    `block in load_translations'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:18:in
    `each'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:18:in
    `load_translations'
    /Users/koic/src/github.com/ruby-i18n/i18n/test/backend/cache_file_test.rb:49:in
    `block (2 levels) in <module:CacheFileTest>'
    /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/tempfile.rb:317:in
    `open'
    /Users/koic/src/github.com/ruby-i18n/i18n/test/backend/cache_file_test.rb:43:in
    `block in <module:CacheFileTest>'

  2) Error:
SimpleCacheFileTest#test_load_translations_caches_file_through_updated_modification_time:
I18n::InvalidLocaleData: can not load translations from
/var/folders/6j/5l8q3y250b97529_tcssrwlm0000gn/T/test20210528-81604-9kcvkm.yml:
#<Psych::DisallowedClass: Tried to load unspecified class: Symbol>
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:245:in
    `rescue in load_yml'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:241:in
    `load_yml'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:226:in
    `load_file'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/cache_file.rb:23:in
    `load_file'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:18:in
    `block in load_translations'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:18:in
    `each'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:18:in
    `load_translations'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/simple.rb:79:in
    `init_translations'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/simple.rb:89:in
    `lookup'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n/backend/base.rb:32:in
    `translate'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n.rb:207:in `block
    in translate'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n.rb:203:in `catch'
    /Users/koic/src/github.com/ruby-i18n/i18n/lib/i18n.rb:203:in
    `translate'
    /Users/koic/src/github.com/ruby-i18n/i18n/test/backend/cache_file_test.rb:50:in
    `block (2 levels) in <module:CacheFileTest>'
    /Users/koic/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/tempfile.rb:317:in
    `open'
    /Users/koic/src/github.com/ruby-i18n/i18n/test/backend/cache_file_test.rb:43:in
    `block in <module:CacheFileTest>'

1658 runs, 2627 assertions, 0 failures, 2 errors, 0 skips
rake aborted!
```

This breaking is because an incompatibility with Psych 4.0.

- ruby/psych#487
- https://bugs.ruby-lang.org/issues/17866

For example, this PR solves the problem of faker gem that depend on i18n gem.
faker-ruby/faker#2330
@koic
Copy link
Member

koic commented May 28, 2021

Thank you for the feedback. I've opened ruby-i18n/i18n#569 to Ruby I18n gem.

@jtenholder
Copy link

@tadman I'm running into the same issue pinning gem 'psych', '3.3.2' didn't seem to fix it. I would put the gem 'psych', '3.3.2' in my project gemfile correct?

@tadman
Copy link
Author

tadman commented Jul 30, 2021

That's what worked for me, but your case might vary.

Honestly this should just be fixed in Faker. Psych 4.x is here to stay and this problem will only become more of a hassle over time.

koic added a commit to koic/faker that referenced this issue Nov 3, 2021
Resolves faker-ruby#2330.

This PR makes Faker require Ruby I18n 1.18.11 or higher to
resolve faker-ruby#2330.
koic added a commit to koic/faker that referenced this issue Nov 3, 2021
Resolves faker-ruby#2330.

This PR makes Faker require Ruby I18n 1.8.11 or higher to
resolve faker-ruby#2330.
@koic koic closed this as completed in #2413 Nov 3, 2021
aclemons pushed a commit to aclemons/faker that referenced this issue Mar 2, 2022
Resolves faker-ruby#2330.

This PR makes Faker require Ruby I18n 1.8.11 or higher to
resolve faker-ruby#2330.
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

Successfully merging a pull request may close this issue.

3 participants