summaryrefslogtreecommitdiff
path: root/lib/bundler/definition.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2023-06-10 00:19:39 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-06-15 07:01:25 +0900
commite86f4c581b274a3e0bb198b1567cc9aa07d95343 (patch)
tree34474353b7f673c7451199999e01aac5b022c1d1 /lib/bundler/definition.rb
parent23ecaab8dd7e7153ee34cc2cdf43df4448d66e41 (diff)
[rubygems/rubygems] Improve frozen mode error message
This error message is also printed when using `bundler/setup` in frozen model, so we're not necessarily installing any gems when it happens. This new message play nicer with all situations. https://github.com/rubygems/rubygems/commit/6874bbacce
Diffstat (limited to 'lib/bundler/definition.rb')
-rw-r--r--lib/bundler/definition.rb25
1 files changed, 11 insertions, 14 deletions
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