Skip to content

Commit f2fde27

Browse files
hsbtmatzbot
authored andcommitted
[ruby/rubygems] Only use parent source with Git and Path sources
ruby/rubygems@c5da276610
1 parent 554ca2e commit f2fde27

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

lib/bundler/definition.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ def converge_specs(specs)
10771077
end
10781078
end
10791079

1080-
if parent_dep
1080+
if parent_dep && parent_dep.source.is_a?(Source::Path)
10811081
replacement_source = parent_dep.source
10821082
else
10831083
replacement_source = sources.get(lockfile_source)

spec/bundler/install/gemfile/sources_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,4 +1195,45 @@
11951195
expect(gem_section).not_to include("activerecord (7.0.0)")
11961196
end
11971197
end
1198+
1199+
context "when a scoped rubygems source is missing a transitive dependency" do
1200+
before do
1201+
build_repo2 do
1202+
build_gem "fallback_dep", "1.0.0"
1203+
build_gem "foo", "1.0.0"
1204+
end
1205+
1206+
build_repo3 do
1207+
build_gem "private_parent", "1.0.0" do |s|
1208+
s.add_dependency "fallback_dep"
1209+
end
1210+
end
1211+
1212+
gemfile <<-G
1213+
source "https://gem.repo2"
1214+
1215+
gem "foo"
1216+
1217+
source "https://gem.repo3" do
1218+
gem "private_parent", "1.0.0"
1219+
end
1220+
G
1221+
1222+
bundle :install, artifice: "compact_index"
1223+
end
1224+
1225+
it "falls back to the default rubygems source for that dependency" do
1226+
build_repo2 do
1227+
build_gem "foo", "2.0.0"
1228+
end
1229+
1230+
system_gems []
1231+
1232+
bundle "update foo", artifice: "compact_index"
1233+
1234+
expect(the_bundle).to include_gems("private_parent 1.0.0", "fallback_dep 1.0.0", "foo 2.0.0")
1235+
expect(the_bundle).to include_gems("private_parent 1.0.0", source: "remote3")
1236+
expect(the_bundle).to include_gems("fallback_dep 1.0.0", source: "remote2")
1237+
end
1238+
end
11981239
end

0 commit comments

Comments
 (0)