Skip to content

Commit a4f8f38

Browse files
hsbtclaude
andcommitted
Mark transitive-only overrides as changed against the lockfile
converge_dependencies only iterates @Dependencies (Gemfile-declared direct deps), so an override that targets a gem present only as a transitive dependency never registered as a change. With an existing lockfile, @dependency_changes stayed false, the resolver was skipped, and the override was a silent no-op. After the direct-dep loop, inspect @OVERRIDES for any String target that is locked but not a direct dep and force it onto @gems_to_unlock / @changed_dependencies so resolution runs and the Resolver-side override hook applies. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 275cbca commit a4f8f38

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

bundler/lib/bundler/definition.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,9 +1054,25 @@ def converge_dependencies
10541054
@changed_dependencies << name if dep_changed
10551055
end
10561056

1057+
converge_overrides_outside_dependencies
1058+
10571059
@changed_dependencies.any?
10581060
end
10591061

1062+
def converge_overrides_outside_dependencies
1063+
@overrides.each do |override|
1064+
next unless override.target.is_a?(String)
1065+
1066+
name = override.target
1067+
next if @changed_dependencies.include?(name)
1068+
next if @dependencies.any? {|d| d.name == name }
1069+
next if @originally_locked_specs[name].empty?
1070+
1071+
@gems_to_unlock << name
1072+
@changed_dependencies << name
1073+
end
1074+
end
1075+
10601076
# Remove elements from the locked specs that are expired. This will most
10611077
# commonly happen if the Gemfile has changed since the lockfile was last
10621078
# generated

spec/install/gemfile/override_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,24 @@
109109

110110
expect(the_bundle).to include_gems "myrack 1.0.0", "myrack_middleware 1.0"
111111
end
112+
113+
it "applies a transitive-only override against an existing lockfile" do
114+
install_gemfile <<-G
115+
source "https://gem.repo1"
116+
gem "myrack_middleware"
117+
G
118+
119+
expect(the_bundle).to include_gems "myrack 0.9.1", "myrack_middleware 1.0"
120+
121+
gemfile <<-G
122+
source "https://gem.repo1"
123+
override "myrack", version: "= 1.0.0"
124+
gem "myrack_middleware"
125+
G
126+
127+
bundle :install
128+
129+
expect(the_bundle).to include_gems "myrack 1.0.0", "myrack_middleware 1.0"
130+
end
112131
end
113132
end

0 commit comments

Comments
 (0)