diff options
-rw-r--r-- | lib/bundler/dsl.rb | 16 | ||||
-rw-r--r-- | spec/bundler/bundler/dsl_spec.rb | 2 |
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 4e38df1ce9..3517a109ed 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -448,14 +448,20 @@ repo_name ||= user_name def check_rubygems_source_safety if @sources.implicit_global_source? - Bundler::SharedHelpers.major_deprecation 2, "This Gemfile does not include an explicit global source. " \ - "Not using an explicit global source may result in a different lockfile being generated depending on " \ - "the gems you have installed locally before bundler is run." \ - "Instead, define a global source in your Gemfile like this: source \"https://rubygems.org\"." + implicit_global_source_warning + elsif @sources.aggregate_global_source? + multiple_global_source_warning end + end - return unless @sources.aggregate_global_source? + def implicit_global_source_warning + Bundler::SharedHelpers.major_deprecation 2, "This Gemfile does not include an explicit global source. " \ + "Not using an explicit global source may result in a different lockfile being generated depending on " \ + "the gems you have installed locally before bundler is run." \ + "Instead, define a global source in your Gemfile like this: source \"https://rubygems.org\"." + end + def multiple_global_source_warning if Bundler.feature_flag.bundler_3_mode? msg = "This Gemfile contains multiple primary sources. " \ "Each source after the first must include a block to indicate which gems " \ diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb index cfc4a7855d..e6cd43ab59 100644 --- a/spec/bundler/bundler/dsl_spec.rb +++ b/spec/bundler/bundler/dsl_spec.rb @@ -245,7 +245,7 @@ RSpec.describe Bundler::Dsl do describe "#check_primary_source_safety" do context "when a global source is not defined implicitly" do it "will raise a major deprecation warning" do - not_a_global_source = double("not-a-global-source", no_remotes?: true, multiple_remotes?: false) + not_a_global_source = double("not-a-global-source", :no_remotes? => true) allow(Bundler::Source::Rubygems).to receive(:new).and_return(not_a_global_source) warning = "This Gemfile does not include an explicit global source. " \ |