Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Warn about downgrading default gems in bundle install - #10026

Merged
hsbt merged 2 commits into
ruby:masterfrom
rhenium:ky/bundler-warn-downgrade-default-gems
Nov 10, 2026
Merged

hsbt merged 2 commits into
ruby:masterfrom
rhenium:ky/bundler-warn-downgrade-default-gems

Conversation

@rhenium

@rhenium rhenium commented Nov 5, 2026

Copy link
Copy Markdown
Member

Downgrading a gem below the default gem version shipped with the running Ruby version is not guaranteed to work. Warn when the bundle contains an older version of a default gem during bundle install or bundle update.

This can be particularly confusing because downgrading a default gem often works, but may also result in a cryptic error. One such case was reported at ruby/net-http#362, where the bundle contains an old version of net-protocol but does not include net-http.

When the application calls require "net/http", the default net-http is loaded as a standard library. Its version requirement on net-protocol is then not honored.


Fixes ruby/net-http#362

For example, if the Gemfile.lock specifies an old version of net-protocol for some reason, bundle install will now warn:

$ bundle install
Your bundle downgrades the following default gems shipped with ruby 4.1.0.dev:
  * net-protocol 0.2.2 (default: 0.4.0)
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

A concern is that this might be annoying for Ruby master users where the default gems set often contains unreleased versions. You'll get a warning whenever the Gemfile contains stringio, since Ruby master currently includes stringio 3.2.1.dev.

BTW there is also a related issue about downgrading Bundler which this PR does not cover: ruby/ruby#16909

I think a warning would be useful there, too, but it will have to be taken care of separately.

What do you think?

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

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

Make sure the following tasks are checked

@rhenium
rhenium force-pushed the ky/bundler-warn-downgrade-default-gems branch 2 times, most recently from c88261b to 6cfcba0 Compare November 6, 2026 16:31
ENV["BUNDLER_GEM_DEFAULT_DIR"] is a Bundler test helper that overrides
Gem.default_dir. Make spec/support/hax.rb rebuild the cache used by
Gem.find_default_spec, which otherwise continues to reference the
original default gems.

Existing tests worked around the stale cache by copying gemspecs, but
this should not be necessary.
Downgrading a gem below the default gem version shipped with the
running Ruby version is not guaranteed to work. Warn when the bundle
contains an older version of a default gem during "bundle install" or
"bundle update".

This can be particularly confusing because downgrading a default gem
often works, but may also result in a cryptic error. One such case
was reported at <ruby/net-http#362>, where
the bundle contains an old version of net-protocol but does not include
net-http.

When the application calls require "net/http", the default net-http is
loaded as a standard library. Its version requirement on net-protocol
is then not honored.
@rhenium
rhenium force-pushed the ky/bundler-warn-downgrade-default-gems branch from 6cfcba0 to e99212f Compare November 6, 2026 16:42
@hsbt

hsbt commented Nov 10, 2026

Copy link
Copy Markdown
Member

I'll look tomorrow.

@hsbt
hsbt merged commit c63e9e6 into ruby:master Nov 10, 2026
114 checks passed
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.

Default net-http 0.10.0 fails every response read next to a locked net-protocol 0.2.2

2 participants