-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Respect encodings when reading gemspecs #6599
Respect encodings when reading gemspecs #6599
Conversation
gem.author = "Ivo Anjo" | ||
gem.summary = "Unscratchable stuff" | ||
end | ||
G |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at how nice the version.rb
file in this diff looks, we might want to change the G
tag to RUBY
everywhere :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me!
lib/bundler.rb
Outdated
@@ -444,7 +444,7 @@ def load_gemspec(file, validate = false) | |||
|
|||
def load_gemspec_uncached(file, validate = false) | |||
path = Pathname.new(file) | |||
contents = read_file(file) | |||
contents = path.read(encoding: Encoding::UTF_8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the CI:
lib/bundler.rb:447:28: C: Style/HashSyntax: Use hash rockets syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, should be fixed now!
1e76cd1
to
74a0058
Compare
lib/bundler.rb
Outdated
@@ -444,7 +444,7 @@ def load_gemspec(file, validate = false) | |||
|
|||
def load_gemspec_uncached(file, validate = false) | |||
path = Pathname.new(file) | |||
contents = read_file(file) | |||
contents = path.read(:encoding => Encoding::UTF_8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's surprising Bundler still supports the very old Ruby 1.8.7.
Maybe File.open(file, "r:UTF-8", &:read)
would work on 1.8.7 too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally, I was bitten by the same thing in the PR that caused this regression as well.
Master (bundle 2) does not really support 1.8.7 anymore (the minimum required ruby version has been bumped to ruby 2.3). However, specs are still run against 1.8.7 in order to "ease backports". In my opinion this is wrong because easing backports comes at the cost of difficulting regular contributions (like this one). But it's no big deal I guess.
Just tried your suggestion, let's see if it works...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info, I agree in general. I filed #6600 just before seeing this, let's see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't work... 😞 Up to the maintainers how to follow up from here.
Maybe it's OK to skip this spec on 1.8.7? |
Fine with me! Let me skip it. |
spec/install/gemspecs_spec.rb
Outdated
@@ -63,6 +63,33 @@ | |||
expect(out).to include("Bundle complete!") | |||
end | |||
|
|||
it "reads gemspecs respecting their encoding" do | |||
skip "Too cool for 1.8" if RUBY_VERSION < "1.9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not informative, please use a comment that explains why we need to skip 1.8 in this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about "unicode was probably not fully supported on 1.8"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically the reason is that we have decided it's not worth even trying to make this work on 1.8. We're not sure it's actually supported and blind guessing from Travis logs feedback is... tough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a new skip message, hopefully more serious and informative :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to skip testing this spec on ruby 1.8.6
@bundlerbot r+ |
📌 Commit 6df5585 has been approved by |
…n, r=colby-swandale Respect encodings when reading gemspecs This PR fixes #6598. Thanks @eregon for the help and the explanation that helped me understand the issue :)! ### What was the end-user problem that led to this PR? On gems using UTF-8 symbols defined in other files in their gemspecs, `bundle install` would crash. ### What was your diagnosis of the problem? The problem was that since #6279 gemspecs are read binarily. However, files required from them as read as text. That means that the constants defined on those files and used in the gemspec are interpreted different and thus don't match. ### What is your fix for the problem, implemented in this PR? My fix is to go back to reading gemspec as text again. Explictly passing the encoding when reading them still fixes the problem that the PR introducing the regression was meant to fix. ### Why did you choose this fix out of the possible options? I chose this fix because it fixes the problem, and keeps the situation that the PR introducing the regression fixed also working.
☀️ Test successful - status-travis |
…n, r=colby-swandale Respect encodings when reading gemspecs This PR fixes #6598. Thanks @eregon for the help and the explanation that helped me understand the issue :)! ### What was the end-user problem that led to this PR? On gems using UTF-8 symbols defined in other files in their gemspecs, `bundle install` would crash. ### What was your diagnosis of the problem? The problem was that since #6279 gemspecs are read binarily. However, files required from them as read as text. That means that the constants defined on those files and used in the gemspec are interpreted different and thus don't match. ### What is your fix for the problem, implemented in this PR? My fix is to go back to reading gemspec as text again. Explictly passing the encoding when reading them still fixes the problem that the PR introducing the regression was meant to fix. ### Why did you choose this fix out of the possible options? I chose this fix because it fixes the problem, and keeps the situation that the PR introducing the regression fixed also working. (cherry picked from commit cb18acc)
This PR fixes #6598. Thanks @eregon for the help and the explanation that helped me understand the issue :)!
What was the end-user problem that led to this PR?
On gems using UTF-8 symbols defined in other files in their gemspecs,
bundle install
would crash.What was your diagnosis of the problem?
The problem was that since #6279 gemspecs are read binarily. However, files required from them as read as text. That means that the constants defined on those files and used in the gemspec are interpreted different and thus don't match.
What is your fix for the problem, implemented in this PR?
My fix is to go back to reading gemspec as text again. Explictly passing the encoding when reading them still fixes the problem that the PR introducing the regression was meant to fix.
Why did you choose this fix out of the possible options?
I chose this fix because it fixes the problem, and keeps the situation that the PR introducing the regression fixed also working.