[rubygems/rubygems] Fix error message when Bundler refuses to install due to frozen being set without a lockfile

https://github.com/rubygems/rubygems/commit/0857d62ca6
This commit is contained in:
David Rodríguez 2024-08-21 18:26:22 +02:00 committed by git
parent 7812732e2c
commit 9f5860407f
2 changed files with 16 additions and 3 deletions

View File

@ -29,9 +29,10 @@ module Bundler
if options[:deployment] || options[:frozen] || Bundler.frozen_bundle?
unless Bundler.default_lockfile.exist?
flag = "--deployment flag" if options[:deployment]
flag ||= "--frozen flag" if options[:frozen]
flag ||= "deployment setting"
flag = "--deployment flag" if options[:deployment]
flag ||= "--frozen flag" if options[:frozen]
flag ||= "deployment setting" if Bundler.settings[:deployment]
flag ||= "frozen setting" if Bundler.settings[:frozen]
raise ProductionError, "The #{flag} requires a lockfile. Please make " \
"sure you have checked your #{SharedHelpers.relative_lockfile_path} into version control " \
"before deploying."

View File

@ -74,6 +74,18 @@ RSpec.describe "install in deployment or frozen mode" do
end
end
it "fails without a lockfile and says that deployment requires a lock" do
bundle "config deployment true"
bundle "install", raise_on_error: false
expect(err).to include("The deployment setting requires a lockfile")
end
it "fails without a lockfile and says that frozen requires a lock" do
bundle "config frozen true"
bundle "install", raise_on_error: false
expect(err).to include("The frozen setting requires a lockfile")
end
it "still works if you are not in the app directory and specify --gemfile" do
bundle "install"
simulate_new_machine