diff options
| author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2026-01-27 18:28:44 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2026-01-28 22:36:57 +0000 |
| commit | f2fde274506fa1731e576d9fca237764103b56db (patch) | |
| tree | 905d5152cc97dede94d7406b20521eb9ccb9255b | |
| parent | 554ca2eb622d1cfe886b419a54293d231a6c19f7 (diff) | |
[ruby/rubygems] Only use parent source with Git and Path sources
https://github.com/ruby/rubygems/commit/c5da276610
| -rw-r--r-- | lib/bundler/definition.rb | 2 | ||||
| -rw-r--r-- | spec/bundler/install/gemfile/sources_spec.rb | 41 |
2 files changed, 42 insertions, 1 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 5ab577f504..639740e46b 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -1077,7 +1077,7 @@ module Bundler end end - if parent_dep + if parent_dep && parent_dep.source.is_a?(Source::Path) replacement_source = parent_dep.source else replacement_source = sources.get(lockfile_source) diff --git a/spec/bundler/install/gemfile/sources_spec.rb b/spec/bundler/install/gemfile/sources_spec.rb index 90f87ed0c5..69b0816a18 100644 --- a/spec/bundler/install/gemfile/sources_spec.rb +++ b/spec/bundler/install/gemfile/sources_spec.rb @@ -1195,4 +1195,45 @@ RSpec.describe "bundle install with gems on multiple sources" do expect(gem_section).not_to include("activerecord (7.0.0)") end end + + context "when a scoped rubygems source is missing a transitive dependency" do + before do + build_repo2 do + build_gem "fallback_dep", "1.0.0" + build_gem "foo", "1.0.0" + end + + build_repo3 do + build_gem "private_parent", "1.0.0" do |s| + s.add_dependency "fallback_dep" + end + end + + gemfile <<-G + source "https://gem.repo2" + + gem "foo" + + source "https://gem.repo3" do + gem "private_parent", "1.0.0" + end + G + + bundle :install, artifice: "compact_index" + end + + it "falls back to the default rubygems source for that dependency" do + build_repo2 do + build_gem "foo", "2.0.0" + end + + system_gems [] + + bundle "update foo", artifice: "compact_index" + + expect(the_bundle).to include_gems("private_parent 1.0.0", "fallback_dep 1.0.0", "foo 2.0.0") + expect(the_bundle).to include_gems("private_parent 1.0.0", source: "remote3") + expect(the_bundle).to include_gems("fallback_dep 1.0.0", source: "remote2") + end + end end |
