-
-
Notifications
You must be signed in to change notification settings - Fork 411
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] UTF-8 YAML files with accents in version 1.9.0 raise incompatible character encodings: UTF-8 and ASCII-8BIT #606
Comments
Hello, thank you for the detailed reproduction steps. I was unable to reproduce this issue using:
(The RSpec versions are highly likely to be irrelevant to this issue) I will try with Ruby 3.0.3 now. |
I am unable to reproduce this issue with 3.0.3. Could you please put a Rails app that does reproduce this issue on GitHub so that I can clone it down and investigate? |
We have a similar issue. I've created this repo to demonstrate the difference. Using i18n 1.8.11 the keys are symbolized with UTF-8 encoding. With 1.9.1 it's ASCII.
(With Ruby 3.0.3) |
Thank you @joergschiller |
Thank you @joergschiller. I can reproduce this issue now with your repository. I'll find the commit that broke it. |
Commit that breaks this behaviour is 0fda789, as discovered through a
|
@paarthmadan Do you have any time today to investigate this one? |
Looked into where the
If I remove
@casperisfine: Would you like me to create an issue on the Bootsnap repo page for this one? |
👀 |
Ah damn it, I know what the problem is. It's because Bootsnap uses msgpack to accelarate YAML parsing, and MessagePack use an API that doesn't preserve symbols encoding properly. See an issue I opened a while ago msgpack/msgpack-ruby#211 Let me go over my old research see how we could sidestep this in bootsnap. I'll update here ASAP. |
Ok, so the bug is actually in You can apply the patch with: gem 'msgpack', github: 'Shopify/msgpack-ruby', branch: 'symbolize-keys-fix-encoding' >> I18n.t(:foobar)
=> {:ö=>"ü"} Alternatively, if you'd rather not run a gem branch, you can disable Bootsnap YAML caching. Sorry for the bug :/ |
Thank you very much for the deep investigation here :) |
@casperisfine Is there something we could do to get that msgpack/msgpack-ruby PR merged + released? Is there a bribe of cookies that needs to be made here? |
Not that I know of. He did acknowledge seeing some of my other PRs, he's probably busy. I don't like to nag maintainers, but I see the same bug was reported again yesterday, so I'll ping him on that on PR just this once. |
He said early next week hopefully. |
If you are interested, I could add some feature checking in |
@casperisfine That could be a good workaround in the meantime, I think. Could you please find out what that would take?? |
Uh, I just come back to this issue, and I was certain I already answered :/ So first the fix was merged upstream today, but not sure when there will be a release. For the workaround, we could simply test wether the bug is present with something like: √: ~ and then from ruby: if YAML.unsafe_load_file("test.yml", symbolize_names: true).keys.first.encoding == Encoding::UTF_8
# it works we can use the optimization
... |
…the bug is present
Reviewing this again, I think we'll just wait for a new I'll be leaving this issue open until that new version is out. |
|
Thank you all for the hard work! 👏🏻 |
For long time I have a code like this:
The yaml file is in UTF-8 and it has accents in some words:
with new release 1.9.0
It starts failing in our CI in a lot of places:
Downgrade to 1.8.11 make everything works again.
With 1.9.0 use rails console it loads like:
With 1.8.11 use rails console it loads like:
The output seems exactly the same.
Is that a bug in new version?
Probably something between new version and load in rails.
This is just a sample
I have others files with accents and all of them are raising same exception.
Versions of i18n, rails, and anything else you think is necessary
ruby: 3.0.3
i18n: 1.9.0
rails: 6.1.4.3
rspec-rails: 5.1.0
rspec: 3.10.0
and
# frozen_string_literal: true
in ruby files.The text was updated successfully, but these errors were encountered: