Fix issue with old rubygems not detecting musl linux properly#40
Merged
Conversation
Old versions of rubygems (for instance 3.0.3) don't properly detect alternative libc implementations on Linux; in particular for our case, they don't detect musl. (For reference, Rubies older than 2.7 may have shipped with an affected version of rubygems). In such cases, we fall back to use RbConfig::CONFIG['arch'] instead. Why not use `RbConfig::CONFIG['arch']` always? Because `Gem::Platform.local.to_s` does some normalization we want in other situations -- for instance, it turns `x86_64-linux-gnu` to `x86_64-linux`. So for now we only add this workaround in a specific situation where we actually know it is wrong. See also ruby/rubygems#2922 and ruby/rubygems#4082 Fixes DataDog/dd-trace-rb#2222
I'm planning to release 0.7.0.1.1 with the musl fix. This will be automatically picked up by customers using the currently-released version of dd-trace-rb (1.3.0).
Otherwise this breaks in Linux due to the rest of the spec flow.
3803a55 to
4c091c0
Compare
marcotc
approved these changes
Aug 18, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fix issue with old rubygems not detecting musl linux properly.
Old versions of rubygems (for instance 3.0.3) don't properly detect alternative libc implementations on Linux; in particular for our case, they don't detect musl.
(For reference, Rubies older than 2.7 may have shipped with an affected version of rubygems).
In such cases, we fall back to use RbConfig::CONFIG['arch'] instead.
Why not use
RbConfig::CONFIG['arch']always? BecauseGem::Platform.local.to_sdoes some normalization we want in other situations -- for instance, it turnsx86_64-linux-gnutox86_64-linux. So for now we only add this workaround in a specific situation where we actually know it is wrong.See also ruby/rubygems#2922 and ruby/rubygems#4082
Fixes DataDog/dd-trace-rb#2222
Motivation
Fix DataDog/dd-trace-rb#2222; customers can manually upgrade to a non-buggy rubygems, but having this fixed on our side provides a better user experience.
Additional Notes
I'll ask someone working on Ruby to review this change, since it's very Ruby-specific.
How to test the change?
The
ruby:2.5.9-alpine3.13docker image ships with an affected version of Rubygems 3.0.3. Without this fix, the following command will print the wrong (non-musl) path for libdatadog:with the new libdatadog (here I install it manually -- you can run
bundle exec rake packageto replicate locally), the correct version gets used: