Skip to content

Commit d8d10c2

Browse files
committed
Merge pull request #9301 from ruby/fallback-git-path-sources
Fallback git/path sources to default source (cherry picked from commit 5b7c8af)
1 parent b74c025 commit d8d10c2

2 files changed

Lines changed: 75 additions & 1 deletion

File tree

bundler/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 && parent_dep.source.is_a?(Source::Path)
1080+
if parent_dep && parent_dep.source.is_a?(Source::Path) && parent_dep.source.specs[s]&.any?
10811081
replacement_source = parent_dep.source
10821082
else
10831083
replacement_source = sources.get(lockfile_source)

bundler/spec/install/gemfile/sources_spec.rb

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,4 +1236,78 @@
12361236
expect(the_bundle).to include_gems("fallback_dep 1.0.0", source: "remote2")
12371237
end
12381238
end
1239+
1240+
context "when a path gem has a transitive dependency that does not exist in the path source" do
1241+
before do
1242+
build_repo2 do
1243+
build_gem "missing_dep", "1.0.0"
1244+
build_gem "foo", "1.0.0"
1245+
end
1246+
1247+
build_lib "parent_gem", "1.0.0", path: lib_path("parent_gem") do |s|
1248+
s.add_dependency "missing_dep"
1249+
end
1250+
1251+
gemfile <<-G
1252+
source "https://gem.repo2"
1253+
1254+
gem "foo"
1255+
1256+
gem "parent_gem", path: "#{lib_path("parent_gem")}"
1257+
G
1258+
1259+
bundle :install, artifice: "compact_index"
1260+
end
1261+
1262+
it "falls back to the default rubygems source for that dependency when updating" do
1263+
build_repo2 do
1264+
build_gem "foo", "2.0.0"
1265+
end
1266+
1267+
system_gems []
1268+
1269+
bundle "update foo", artifice: "compact_index"
1270+
1271+
expect(the_bundle).to include_gems("parent_gem 1.0.0", "missing_dep 1.0.0", "foo 2.0.0")
1272+
expect(the_bundle).to include_gems("parent_gem 1.0.0", source: "path@#{lib_path("parent_gem")}")
1273+
expect(the_bundle).to include_gems("missing_dep 1.0.0", source: "remote2")
1274+
end
1275+
end
1276+
1277+
context "when a git gem has a transitive dependency that does not exist in the git source" do
1278+
before do
1279+
build_repo2 do
1280+
build_gem "missing_dep", "1.0.0"
1281+
build_gem "foo", "1.0.0"
1282+
end
1283+
1284+
build_git "parent_gem", "1.0.0", path: lib_path("parent_gem") do |s|
1285+
s.add_dependency "missing_dep"
1286+
end
1287+
1288+
gemfile <<-G
1289+
source "https://gem.repo2"
1290+
1291+
gem "foo"
1292+
1293+
gem "parent_gem", git: "#{lib_path("parent_gem")}"
1294+
G
1295+
1296+
bundle :install, artifice: "compact_index"
1297+
end
1298+
1299+
it "falls back to the default rubygems source for that dependency when updating" do
1300+
build_repo2 do
1301+
build_gem "foo", "2.0.0"
1302+
end
1303+
1304+
system_gems []
1305+
1306+
bundle "update foo", artifice: "compact_index"
1307+
1308+
expect(the_bundle).to include_gems("parent_gem 1.0.0", "missing_dep 1.0.0", "foo 2.0.0")
1309+
expect(the_bundle).to include_gems("parent_gem 1.0.0", source: "git@#{lib_path("parent_gem")}")
1310+
expect(the_bundle).to include_gems("missing_dep 1.0.0", source: "remote2")
1311+
end
1312+
end
12391313
end

0 commit comments

Comments
 (0)