-
Notifications
You must be signed in to change notification settings - Fork 188
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
Error when using special characters in Gemfile: "incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)" #1376
Comments
Hello, I can reproduce the issue. |
OK, one difference is instance_eval "\xF0\x9F\x92\x8E\n".b
# or
instance_eval "💎".b gives on MRI
while on TruffleRuby it gives:
So basically on MRI the missing method is handled by
And the binary encoding of the description seems quite lucky for Bundler, and it's there because the method_missing is defined like: def method_missing(name, *args)
raise PluginGemfileError, "Undefined local variable or method `#{name}' for Gemfile" unless Bundler::Dsl.method_defined? name
end and the passed So this works by luck, in m = "\n[!] " # UTF-8, CR-7BIT
# If description is binary, then m becomes binary too
# if not it stays UTF-8, but becomes CR-VALID (not only US-ASCII)
m << description
...
# If m is already BINARY, all fine
# If m is UTF-8 CR-VALID and we append a BINARY string => Encoding::CompatibilityError
m << lines[line_numer] # the same as m << "\xF0\x9F\x92\x8E\n".b
Anyway, the first thing we need to do is figure out why TruffleRuby think 💎 is a constant and not a local variable/method call. |
Thanks for the awesome deep dive and quick answer! 🎉 |
Sorry for so much text 😄 If this was UTF-8, we would just deal with valid Strings but here it means the Gemfile is just a sequence of bytes, and it's unknown how to interpreter them into characters. I think it's more important to make |
No, please do! 👍
Shouldn't it default to UTF-8 even without the I believe that from Ruby 2.0 it's the default; I've only added it to the gem so as to also support 1.9.3 (I have a lot of hacks to support all the Ruby versions I can -- this gem stretches Ruby/JRuby in really funny ways). |
Ruby defaults to UTF-8 for running the main script and MRI also fails
Could you verify that in your environment actually? |
I stand corrected, indeed the I went back to check and when I added support for Ruby 1.9.3 this wasn't needed: https://gitlab.com/ivoanjo/persistent-dmnd/commit/29d0977df8429ed1617f07d325b3b6169dc6154e. So I dug a little deeper and it seems this was introduced in the latest bundler point release:
So I decided to try bundler 1.16.1 with truffleruby and indeed it works:
I could also run the specs, saw a few ones broken related to concurrent-ruby, I'll need to check to see if I should report them here or there. So it appears this issue only happens with bundler 1.16.2. |
Thank you for confirming! In the meanwhile, I now have a fix locally so TruffleRuby reads the magic comment and Please file another issue for the broken specs related to concurrent-ruby, to make it easier to track. |
Sounds good, I'll report the upstream issues. It's really nice to see that otherwise TruffleRuby seems to handle the emoji really well -- I was half expecting to trigger a few corner cases there 😉 😈 |
Concurrent-ruby issues should be fixed with ruby-concurrency/concurrent-ruby#734 |
The fixes are now in master: 9f48ac1...e732478 , including extensive specs for the magic comments and a few encoding-related fixes. They will be in the next release. This fixes For the |
The main issue of running |
For information, bb6c24e is the new change that fails early when trying to eval a binary String with no magic encoding comment (mentioned above), and avoids mis-encoding binary strings. |
Hello there!
truffleruby 1.0.0-rc2, like ruby 2.4.4, GraalVM CE Native [x86_64-linux]
Linux maruhime 4.13.0-45-generic #50-Ubuntu SMP Wed May 30 08:23:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu 17.10
I was trying out my oddly-named Persistent-💎 gem, where I use the
💎
on several method and class names, and unfortunately doingbundle install
I get antruffleruby: incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)
.I was able to create the smallest test case for a failure ever: just create a
Gemfile
with the following:and here is the result:
on MRI I get:
(And of course, on MRI, doing
bundle install
with the full normal gem works).The text was updated successfully, but these errors were encountered: