Fix issue with old rubygems not detecting musl linux properly #40
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_s
does some normalization we want in other situations -- for instance, it turnsx86_64-linux-gnu
tox86_64-linux
. So for now we only add this workaround in a specific situation where we actually know it is wrong.See also rubygems/rubygems#2922 and rubygems/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.13
docker 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 package
to replicate locally), the correct version gets used: