Skip to content

Conversation

@jeremy
Copy link
Contributor

@jeremy jeremy commented Dec 18, 2025

When installing in frozen mode with a lockfile that includes platform-specific gems, Bundler now falls back to the generic ruby platform gem if the platform-specific variant has an incompatible required_ruby_version.

This addresses scenarios where native gems are precompiled for Ruby versions up to 3.4 (with required_ruby_version < 3.5.dev) but the generic ruby gem works with Ruby 4.0. Previously, Bundler would select the incompatible precompiled gem and fail at install time.

The fallback only applies in frozen mode. In non-frozen mode, Bundler continues to re-resolve and update the lockfile as before.

(Note: When this fallback occurs, the existing "platform specific gems are getting installed" warning may be shown. The message was written for the opposite scenario and could be improved in a follow-up.)

Make sure the following tasks are checked

@jeremy jeremy force-pushed the ruby-platform-fallback-on-incompatible-ruby-version branch from b8fab1b to 6a609e3 Compare December 18, 2025 18:59
@jeremy jeremy changed the title Fall back to ruby platform when precompiled gem has incompatible required_ruby_version Fall back to ruby platform gem when precompiled variant is incompatible Dec 18, 2025
@jeremy jeremy force-pushed the ruby-platform-fallback-on-incompatible-ruby-version branch 3 times, most recently from 72e2f26 to 998b1da Compare December 18, 2025 19:51
jeremy added a commit to basecamp/fizzy that referenced this pull request Dec 18, 2025
* Bundler 4.0.2
* Gem upgrades for Ruby 4 compat
  * rubocop 1.82.0 for rubocop/rubocop#14644
  * web-push 3.1.0 for pushpad/web-push#19
* Git sources for fixes and pending releases
  * rinku: vmg/rinku#97
* Many platform-specific gems aren't compiled for Ruby 4 yet, which
  triggers a Bundler bug wherein it selects a chooses an imcompatible
  platform-specific gem rather than falling back to the ruby platform
  and compiling. Fix: ruby/rubygems#9211
jeremy added a commit to basecamp/fizzy that referenced this pull request Dec 18, 2025
* Bundler 4.0.2
* Gem upgrades for Ruby 4 compat
  * rubocop 1.82.0 for rubocop/rubocop#14644
  * web-push 3.1.0 for pushpad/web-push#19
* Git sources for fixes and pending releases
  * rinku: vmg/rinku#97
* Many platform-specific gems aren't compiled for Ruby 4 yet, which
  triggers a Bundler bug wherein it selects a chooses an imcompatible
  platform-specific gem rather than falling back to the ruby platform
  and compiling. Fix: ruby/rubygems#9211
jeremy added a commit to basecamp/fizzy that referenced this pull request Dec 18, 2025
* Bundler 4.0.2
* Gem upgrades for Ruby 4 compat
  * rubocop 1.82.0 for rubocop/rubocop#14644
  * web-push 3.1.0 for pushpad/web-push#19
* Git sources for fixes and pending releases
  * rinku: vmg/rinku#97
* Many platform-specific gems aren't compiled for Ruby 4 yet, which
  triggers a Bundler bug wherein it selects a chooses an imcompatible
  platform-specific gem rather than falling back to the ruby platform
  and compiling. Fix: ruby/rubygems#9211
@jeremy jeremy mentioned this pull request Dec 18, 2025
3 tasks
jeremy added a commit to basecamp/fizzy that referenced this pull request Dec 18, 2025
* Bundler 4.0.2
* Gem upgrades for Ruby 4 compat
  * rubocop 1.82.0 for rubocop/rubocop#14644
  * web-push 3.1.0 for pushpad/web-push#19
* Git sources for fixes and pending releases
  * rinku: vmg/rinku#97
* Many platform-specific gems aren't compiled for Ruby 4 yet, which
  triggers a Bundler bug wherein it selects a chooses an imcompatible
  platform-specific gem rather than falling back to the ruby platform
  and compiling. Fix: ruby/rubygems#9211
When installing in frozen mode with a lockfile that includes platform-
specific gems, Bundler now falls back to the generic ruby platform gem
if the platform-specific variant has an incompatible required_ruby_version.

This addresses scenarios where native gems are precompiled for Ruby
versions up to 3.4 (with required_ruby_version < 3.5.dev) but the
generic ruby gem works with Ruby 4.0. Previously, Bundler would select
the incompatible precompiled gem and fail at install time.

The fallback only applies in frozen mode. In non-frozen mode, Bundler
continues to re-resolve and update the lockfile as before.

Note: When this fallback occurs, the existing "platform specific gems
are getting installed" warning may be shown. The message was written
for the opposite scenario and could be improved in a follow-up.
@jeremy jeremy force-pushed the ruby-platform-fallback-on-incompatible-ruby-version branch from 998b1da to 62375e0 Compare December 18, 2025 22:10
jeremy added a commit to basecamp/fizzy that referenced this pull request Dec 18, 2025
* Bundler 4.0.2
* Gem upgrades for Ruby 4 compat
  * rubocop 1.82.0 for rubocop/rubocop#14644
  * web-push 3.1.0 for pushpad/web-push#19
* Git sources for fixes and pending releases
  * rinku: vmg/rinku#97
* Many platform-specific gems aren't compiled for Ruby 4 yet, which
  triggers a Bundler bug wherein it selects a chooses an imcompatible
  platform-specific gem rather than falling back to the ruby platform
  and compiling. Fix: ruby/rubygems#9211
Copy link
Member

@hsbt hsbt left a comment

Choose a reason for hiding this comment

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

I still don't understand the entire code before this change, but I got that this change allows us to achieve what is written in the explanation.

@hsbt hsbt merged commit 9660f56 into ruby:master Dec 23, 2025
81 checks passed
hsbt added a commit that referenced this pull request Dec 23, 2025
…atible-ruby-version

Fall back to ruby platform gem when precompiled variant is incompatible

(cherry picked from commit 9660f56)
@hsbt
Copy link
Member

hsbt commented Dec 23, 2025

@jeremy /cc @flavorjones I released 4.0.3 with this.

https://github.com/ruby/rubygems/releases/tag/bundler-v4.0.3

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.

2 participants