Skip to content
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

Backport non gnu libc linux support from RubyGems #4488

Merged

Conversation

lloeki
Copy link
Contributor

@lloeki lloeki commented Mar 24, 2021

What was the end-user or developer problem that led to this PR?

See #3174, #4082, #4425.

What is your fix for the problem, implemented in this PR?

Implement the non-ideal but pragmatic behaviour we agreed upon:

  • "the previous state of things" i.e nil version in gems is a wildcard (i.e a linux gem it can be picked by Rubies on linux and linux-musl)
  • with the exception that if there's a linux-musl variant, it should always be preferred on Alpine (i.e a linux-musl Ruby)
  • and a mirror constraint that on a linux Ruby it should never pick linux-musl gems

Make sure the following tasks are checked

@lloeki
Copy link
Contributor Author

lloeki commented Mar 24, 2021

So, this is WIP: previous work + messy SAVEPOINT commit that I'll clean up later, but I needed to push some base to discuss upon.

I did it TDD/BDD by adding rubygems and bundler tests that make sense WRT the behaviour, and made them pass.

There's still some strange behaviour that I hacked in/out, so I'm not entirely sure I did not create breakage at this stage on other platforms. I also saw some strange things I can't seem to wrap my head around: most likely I'm missing something but they could be legacy code, or bugs.

I'll continue working on this as I figure things out.

CONTRIBUTING.md Outdated Show resolved Hide resolved
lib/rubygems/platform.rb Outdated Show resolved Hide resolved

# musl and explicit gnu should differ
# refute(x86_linux_gnu === x86_linux_musl, 'linux-gnu =~ linux-musl')
# refute(x86_linux_musl === x86_linux_gnu, 'linux-musl =~ linux-gnu')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth thinking about introducing linux-gnu someday, for those good willed maintainers that know their binary is definitely not musl compatible but with no linux-musl published (yet, or ever).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did introduce checks for this but I think we may be getting ahead of ourselves, I'm not fully sure whether we should include it with this patch or not.

refute(x86_linux_musl === x86_linux, 'linux-musl =~ linux')

# other libc are not glibc compatible
# refute(x86_linux === x86_linux_uclibc, 'linux =~ linux-uclibc')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case of these non-musl, non-gnu libc that are known not to be compatible at all with glibc binaries (so zero chance of linux working) remains unsolved here. Anecdotal I know, but one day musl was anecdotal as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this one too! Never seen these in the wild, but if they're not compatible it seems good to make sure we never match "standard" linux.

@deivid-rodriguez
Copy link
Member

@lloeki I left a few comments, hopefully they can help 🙏.

@nightpool
Copy link

After trying to upgrade to mini_racer 0.4.0 and libv8-node this weekend, I found that this issue has broken my Heroku deployment:

remote:        Fetching libv8-node 15.14.0.1 (x86_64-linux-musl)
remote:        Installing libv8-node 15.14.0.1 (x86_64-linux-musl)
....
remote:        Bundle completed (183.45s)
remote:        Cleaning up the bundler cache.
remote:        Could not find libv8-node-15.14.0.1 in any of the sources
remote: -----> Writing config/database.yml to read from DATABASE_URL
remote: -----> Detecting rake tasks
remote:        Could not detect rake tasks
remote:        ensure you can run `$ bundle exec rake -P` against your app
remote:        and using the production group of your Gemfile.
remote:        /tmp/build_3933b252/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/spec_set.rb:91:in `block in materialize': Could not find libv8-node-15.14.0.1 in any of the sources (Bundler::GemNotFound)
remote:        	from /tmp/build_3933b252/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/spec_set.rb:85:in `map!'
remote:        	from /tmp/build_3933b252/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/spec_set.rb:85:in `materialize'
remote:        	from /tmp/build_3933b252/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/definition.rb:170:in `specs'
remote:        	from /tmp/build_3933b252/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/definition.rb:237:in `specs_for'
remote:        	from /tmp/build_3933b252/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/definition.rb:226:in `requested_specs'
remote:        	from /tmp/build_3933b252/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:108:in `block in definition_method'
remote:        	from /tmp/build_3933b252/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:20:in `setup'
remote:        	from /tmp/build_3933b252/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler.rb:107:in `setup'
remote:        	from /tmp/build_3933b252/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/setup.rb:20:in `<top (required)>'
remote:        	from /tmp/build_3933b252/vendor/ruby-2.5.8/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
remote:        	from /tmp/build_3933b252/vendor/ruby-2.5.8/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
remote:        	from /tmp/build_3933b252/vendor/bundle/bin/rake:27:in `<main>'

At least, I'm assuming that this is the same issue? Is there any known workaround?

@lloeki
Copy link
Contributor Author

lloeki commented May 26, 2021

Might be, it fetches linux-musl when (I assume) Heroku is glibc-based?

I really have to find some time to get back on this and finish the PR (should happen soon)

@nightpool
Copy link

nightpool commented May 26, 2021

Thanks @lloeki. I'm not sure why it would be giving that specific error though, considering that there aren't any issues at build time. I also tried pushing the precompiled x86_64 gem to my github rubygems server (here) and got a very similar error:

remote:        Fetching libv8-node 15.14.0.1
remote:        Installing libv8-node 15.14.0.1
[...]
remote:        Bundle completed (182.41s)
remote:        Cleaning up the bundler cache.
remote:        Could not find libv8-node-15.14.0.1 in any of the sources
remote: -----> Writing config/database.yml to read from DATABASE_URL
remote: -----> Detecting rake tasks
remote:        Could not detect rake tasks
remote:        ensure you can run `$ bundle exec rake -P` against your app
remote:        and using the production group of your Gemfile.
remote:        /tmp/build_4900502f/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/spec_set.rb:91:in `block in materialize': Could not find libv8-node-15.14.0.1 in any of the sources (Bundler::GemNotFound)
remote:        	from /tmp/build_4900502f/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/spec_set.rb:85:in `map!'
remote:        	from /tmp/build_4900502f/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/spec_set.rb:85:in `materialize'
remote:        	from /tmp/build_4900502f/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/definition.rb:170:in `specs'
remote:        	from /tmp/build_4900502f/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/definition.rb:237:in `specs_for'
remote:        	from /tmp/build_4900502f/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/definition.rb:226:in `requested_specs'
remote:        	from /tmp/build_4900502f/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:108:in `block in definition_method'
remote:        	from /tmp/build_4900502f/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:20:in `setup'
remote:        	from /tmp/build_4900502f/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler.rb:107:in `setup'
remote:        	from /tmp/build_4900502f/vendor/bundle/ruby/2.5.0/gems/bundler-1.17.3/lib/bundler/setup.rb:20:in `<top (required)>'
remote:        	from /tmp/build_4900502f/vendor/ruby-2.5.8/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
remote:        	from /tmp/build_4900502f/vendor/ruby-2.5.8/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
remote:        	from /tmp/build_4900502f/vendor/bundle/bin/rake:27:in `<main>'

@lloeki
Copy link
Contributor Author

lloeki commented Oct 13, 2021

(should happen soon)

Hah, joke's on me. No time for now but I'm not forgetting about this.

@lloeki
Copy link
Contributor Author

lloeki commented Nov 10, 2021

I'm going to try to redo this based on the rubygems 3.0 + bundler 1.17 patch I produced, which seems to produce good results. Of course only the specs will tell if it fully works.

@wwahammy
Copy link

@lloeki thanks for all the work so far on this! Is there anything I can do to help get this across the finish line? I'm certainly not familiar with the bundler source but I'm happy to help in any way I can.

@virusman
Copy link

@lloeki Any hope for this to get merged?

@lloeki
Copy link
Contributor Author

lloeki commented Mar 10, 2022

@virusman not as is.

FYI I'm rethinking how it should work and what the expectations of the platform.version component should be so that it doesn't break anything.

Do you have a need for a specific gem outside of mini_racer? The more information I have about how people use multiple libc, the better.

@vbabenkoru
Copy link

vbabenkoru commented Mar 11, 2022

Yeah I need this for mini_racer… The changes in rubygems and bundler broke it, and I can’t even deploy the current version of my app without downgrading rubygems and bundler because of that. No workarounds I’ve seen have worked for bundler.

@J0WI
Copy link

J0WI commented Mar 17, 2022

Do you have a need for a specific gem outside of mini_racer?

@ronaldtse
Copy link

We're also encountering this issue with 4 other gems:

On Alpine with Ruby 3.1 (3.1-alpine at https://hub.docker.com/_/ruby) we are seeing the installation of a libc gem (x86_64-linux) but it fails on inclusion due to musl being unable to load a libc compiled library.

The only two options we have as gem maintainers are:

  1. The x86_64-linux platform gem works natively on musl. As @lloeki says it can be impractical.
  2. We publish platform gems for x86_64-linux-musl so that on Alpine the x86_64-linux-musl is always used.

cc: @maxirmx @alexeymorozov @CAMOBAP

@hsbt
Copy link
Member

hsbt commented Mar 26, 2022

At first, the current ruby language is not supported alpine linux and musl officially. The ruby core team does not testing them with https://rubyci.org/

@ronaldtse
Copy link

Thanks @hsbt for the clarification! It was confusing whether it is supported or not given that the Ruby docker images include one built on Alpine... I guess it's a good time to investigate.

@hsbt
Copy link
Member

hsbt commented Mar 26, 2022

I understood alpine image was published by docker team. But the ruby core team didn't work together it. we have our official docker image only https://github.com/ruby/ruby-docker-images/pkgs/container/ruby .

This means the native extension built by musl may not works well with the ruby language. I highly recommend to use debian based image or official docker image published by the ruby core team.

@deivid-rodriguez deivid-rodriguez force-pushed the support-non-gnu-libc-linux-2 branch 2 times, most recently from 70fe6f8 to 4b7723d Compare August 8, 2022 13:14
Co-authored-by: Loic Nageleisen <loic.nageleisen@gmail.com>
@deivid-rodriguez deivid-rodriguez changed the title Support non gnu libc linux (part 2) Backport non gnu libc linux support from RubyGems Aug 22, 2022
@deivid-rodriguez
Copy link
Member

I merged the RubyGems part of this separately at #5852, and this PR now only backports the feature to Bundler so that this works consistently across RubyGems version. I only backported all the way back to RubyGems 3.1.0.pre.1 because trying to backport further required further changes and was a mess.

@ronaldtse
Copy link

Thank you @deivid-rodriguez for #5852 ! We look forward to seeing this merged too and getting to work with non-glibc platforms!

@deivid-rodriguez
Copy link
Member

Thank @lloeki, he did all the heavy lifting! :)

@lloeki
Copy link
Contributor Author

lloeki commented Aug 23, 2022

You're welcome, there were so many users impacted by this I could don't let that one slide :)

@ronaldtse
Copy link

Of course a huge thank you to @lloeki ! Looking forward to publishing platform gems for musl...

@deivid-rodriguez deivid-rodriguez merged commit 95114c8 into rubygems:master Aug 24, 2022
deivid-rodriguez added a commit that referenced this pull request Aug 24, 2022
Backport non gnu libc linux support from RubyGems

(cherry picked from commit 95114c8)
@ronaldtse
Copy link

ronaldtse commented Aug 24, 2022

Thank you for merging! Now we're going to start working!

@deivid-rodriguez
Copy link
Member

Unfortunately, this PR created again a regression in musl platforms 😬. I'll try hard to fix it to hopefully avoid having to revert the feature.

penguinspiral added a commit to penguinspiral/jekyll-blog that referenced this pull request Dec 4, 2022
Recent updates of the Ruby Gem dependency management utility, 'bundler',
introduced a breakage to the 'jekyll-theme-chirper' Ruby Gem starting
from version v2.3.21: rubygems/rubygems#4488

```
2022-12-03T02:23:00.509Z [WARNING]: Could not find gem
'jekyll-theme-chirpy (~> 5.2, >= 5.2.1)' with platform
                                    'x86_64-linux' in rubygems
repository https://rubygems.org/ or installed
                                    locally.
                                    The source contains the following
gems matching 'jekyll-theme-chirpy (~> 5.2, >=
                                    5.2.1)':
                                    * jekyll-theme-chirpy-5.2.1
                                    * jekyll-theme-chirpy-5.3.0
                                    * jekyll-theme-chirpy-5.3.1
                                    * jekyll-theme-chirpy-5.3.2


```

The Ruby Gem dependency management utility, 'bundler', has the same
functionality as its aliased variant 'bundle` (ref:
rubygems/bundler@2894378).

To simplify the AWS Amplify CI/CD pipeline this commit leverages the
'bundle' utility preinstalled in the 'Amazon Linux:2' build image (Docker
container).

The 'Amazon Linux:2' build image contains 'bundle' version 2.0.1. This
version was released almost 4 years ago:
rubygems/bundler@d7ad219.
The latest version of 'bundler' currently available is 2.3.26, however
penguinspiral added a commit to penguinspiral/jekyll-blog that referenced this pull request Dec 4, 2022
Recent updates of the Ruby Gem dependency management utility, 'bundler',
introduced a breakage to the 'jekyll-theme-chirper' Ruby Gem starting
from version v2.3.21: rubygems/rubygems#4488

```
2022-12-03T02:23:00.509Z [WARNING]: Could not find gem
'jekyll-theme-chirpy (~> 5.2, >= 5.2.1)' with platform
                                    'x86_64-linux' in rubygems
repository https://rubygems.org/ or installed
                                    locally.
                                    The source contains the following
gems matching 'jekyll-theme-chirpy (~> 5.2, >=
                                    5.2.1)':
                                    * jekyll-theme-chirpy-5.2.1
                                    * jekyll-theme-chirpy-5.3.0
                                    * jekyll-theme-chirpy-5.3.1
                                    * jekyll-theme-chirpy-5.3.2


```

This commit is intended to serve as a stop-gap solution until all existing
blog content has been migrated to AWS Amplify.
penguinspiral added a commit to penguinspiral/jekyll-blog that referenced this pull request Dec 4, 2022
Recent updates of the Ruby Gem dependency management utility, 'bundler',
introduced a breakage to the 'jekyll-theme-chirpy' Ruby Gem starting
from version v2.3.21: rubygems/rubygems#4488

```
2022-12-03T02:23:00.509Z [WARNING]: Could not find gem
'jekyll-theme-chirpy (~> 5.2, >= 5.2.1)' with platform
                                    'x86_64-linux' in rubygems
repository https://rubygems.org/ or installed
                                    locally.
                                    The source contains the following
gems matching 'jekyll-theme-chirpy (~> 5.2, >=
                                    5.2.1)':
                                    * jekyll-theme-chirpy-5.2.1
                                    * jekyll-theme-chirpy-5.3.0
                                    * jekyll-theme-chirpy-5.3.1
                                    * jekyll-theme-chirpy-5.3.2


```

This commit is intended to serve as a stop-gap solution until all existing
blog content has been migrated to AWS Amplify.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants