From aed528a95cce3fbcc66fbff80d54a76ecc5850fb Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 26 Oct 2026 17:13:46 +0900 Subject: [PATCH] [ruby/rubygems] Rewrite the OVERRIDES section without resolving again An override change made the lockfile count as needing resolution, so `bundle install` fetched the remote index and failed offline when the compact index cache was absent, and `Bundler.setup` re-resolved on boot. The section only needs to be regenerated, which #write_lock already does when the contents differ, and the frozen check still reports the change. https://github.com/ruby/rubygems/commit/a616f3d1bb Co-Authored-By: Claude Opus 5.5 --- lib/bundler/definition.rb | 9 ++++++--- spec/bundler/install/gemfile/override_spec.rb | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index c6c104b5ff5..3d52eaf87cf 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -667,8 +667,7 @@ module Bundler @locked_spec_with_missing_checksums || empty_checksums_actionable? || @locked_spec_with_missing_deps || - @locked_spec_with_invalid_deps || - @override_changes + @locked_spec_with_invalid_deps end def resolve_needed? @@ -920,6 +919,8 @@ module Bundler else lockfile_changed_reason end + elsif @override_changes + "the overrides in your gemfile changed" else "some dependencies were deleted from your gemfile" end @@ -1160,7 +1161,9 @@ module Bundler # The lockfile records the Gemfile's overrides, so a change to them is a # change to the lockfile even when every locked version still satisfies - # them. + # them. Rewriting the section needs no resolution, so this stays out of + # #something_changed?. #write_lock rewrites it because the generated + # contents differ, and the frozen check reports it. def converge_overrides return false unless @locked_gems diff --git a/spec/bundler/install/gemfile/override_spec.rb b/spec/bundler/install/gemfile/override_spec.rb index 9b7012d8740..c38f25ec832 100644 --- a/spec/bundler/install/gemfile/override_spec.rb +++ b/spec/bundler/install/gemfile/override_spec.rb @@ -281,6 +281,23 @@ RSpec.describe "override DSL" do expect(lockfile).to include("myrack (1.0.0)") end + it "records an override change without fetching from the source" do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + + gemfile <<-G + source "https://gem.repo1" + override :all, required_ruby_version: :ignore_upper + gem "myrack" + G + + FileUtils.rm_rf(compact_index_cache_path) + bundle :install, artifice: "fail" + expect(lockfile).to include("OVERRIDES\n :all, required_ruby_version: :ignore_upper\n") + end + it "treats equivalent requirement spellings as the same override" do install_gemfile <<-G source "https://gem.repo1"