diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 1713973236..5db59efe03 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -364,18 +364,6 @@ module Bundler end def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false) - msg = String.new - msg << "You are trying to install in frozen mode after changing your Gemfile.\n" \ - "Run `bundle install` elsewhere and add the updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control.\n" - - unless explicit_flag - suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env) - "bundle config set frozen false" - end - msg << "If this is a development machine, remove the #{Bundler.default_gemfile.relative_path_from(SharedHelpers.pwd)} " \ - "freeze by running `#{suggested_command}`." if suggested_command - end - added = [] deleted = [] changed = [] @@ -405,11 +393,20 @@ module Bundler end reason = change_reason - msg << "\n\n#{reason.split(", ").map(&:capitalize).join("\n")}" + msg = String.new + msg << "#{reason.capitalize.strip}, but the lockfile can't be updated because frozen mode is set" msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any? msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any? msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any? - msg << "\n" + msg << "\n\nRun `bundle install` elsewhere and add the updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control.\n" + + unless explicit_flag + suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env) + "bundle config set frozen false" + end + msg << "If this is a development machine, remove the #{Bundler.default_gemfile.relative_path_from(SharedHelpers.pwd)} " \ + "freeze by running `#{suggested_command}`." if suggested_command + end raise ProductionError, msg if added.any? || deleted.any? || changed.any? || !nothing_changed? end diff --git a/spec/bundler/commands/inject_spec.rb b/spec/bundler/commands/inject_spec.rb index 7d95fe5085..d711fe010d 100644 --- a/spec/bundler/commands/inject_spec.rb +++ b/spec/bundler/commands/inject_spec.rb @@ -109,7 +109,7 @@ Usage: "bundle inject GEM VERSION" gem "rack-obama" G bundle "inject 'rack' '> 0'", :raise_on_error => false - expect(err).to match(/trying to install in frozen mode after changing/) + expect(err).to match(/the lockfile can't be updated because frozen mode is set/) expect(bundled_app_lock.read).not_to match(/rack-obama/) end diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index b7a86fb99b..df69de44d2 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -658,27 +658,27 @@ RSpec.describe "bundle update" do bundle "update", :all => true, :raise_on_error => false expect(last_command).to be_failure - expect(err).to match(/You are trying to install in frozen mode after changing your Gemfile/) + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/) expect(err).to match(/freeze by running `bundle config set frozen false`./) end it "should fail loudly when frozen is set globally" do bundle "config set --global frozen 1" bundle "update", :all => true, :raise_on_error => false - expect(err).to match(/You are trying to install in frozen mode after changing your Gemfile/). + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/). and match(/freeze by running `bundle config set frozen false`./) end it "should fail loudly when deployment is set globally" do bundle "config set --global deployment true" bundle "update", :all => true, :raise_on_error => false - expect(err).to match(/You are trying to install in frozen mode after changing your Gemfile/). + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/). and match(/freeze by running `bundle config set frozen false`./) end it "should not suggest any command to unfreeze bundler if frozen is set through ENV" do bundle "update", :all => true, :raise_on_error => false, :env => { "BUNDLE_FROZEN" => "true" } - expect(err).to match(/You are trying to install in frozen mode after changing your Gemfile/) + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/) expect(err).not_to match(/by running/) end end diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index 799e50c5ab..5dcbf91e33 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -473,7 +473,7 @@ RSpec.describe "install in deployment or frozen mode" do run "require 'rack'", :raise_on_error => false expect(err).to include strip_whitespace(<<-E).strip -The dependencies in your gemfile changed +The dependencies in your gemfile changed, but the lockfile can't be updated because frozen mode is set (Bundler::ProductionError) You have added to the Gemfile: * rack (= 1.0.0) @@ -506,7 +506,7 @@ You have deleted from the Gemfile: simulate_new_machine bundle "config set --local deployment true" bundle "install --verbose" - expect(out).not_to include("You are trying to install in frozen mode after changing your Gemfile") + expect(out).not_to include("but the lockfile can't be updated because frozen mode is set") expect(out).not_to include("You have added to the Gemfile") expect(out).not_to include("You have deleted from the Gemfile") expect(out).to include("vendor/cache/foo") diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb index 80de05aca9..73f04f071d 100644 --- a/spec/bundler/install/gemfile/gemspec_spec.rb +++ b/spec/bundler/install/gemfile/gemspec_spec.rb @@ -150,7 +150,7 @@ RSpec.describe "bundle install from an existing gemspec" do output = bundle("install", :dir => tmp.join("foo")) expect(output).not_to match(/You have added to the Gemfile/) expect(output).not_to match(/You have deleted from the Gemfile/) - expect(output).not_to match(/install in frozen mode after changing/) + expect(output).not_to match(/the lockfile can't be updated because frozen mode is set/) end it "should match a lockfile without needing to re-resolve" do