Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make frozen setting take precedence over deployment setting #6685

Merged
merged 3 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions bundler/lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,10 @@ def definition(unlock = nil)
end

def frozen_bundle?
frozen = settings[:deployment]
frozen ||= settings[:frozen]
frozen
frozen = settings[:frozen]
return frozen unless frozen.nil?

settings[:deployment]
end

def locked_gems
Expand Down
6 changes: 2 additions & 4 deletions bundler/lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,8 @@ def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
"updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."

unless explicit_flag
suggested_command = if Bundler.settings.locations("frozen").keys.&([:global, :local]).any?
"bundle config unset frozen"
elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
"bundle config unset deployment"
suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env)
"bundle config set frozen false"
end
msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
"freeze \nby running `#{suggested_command}`." if suggested_command
Expand Down
10 changes: 5 additions & 5 deletions bundler/spec/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -659,21 +659,21 @@

expect(last_command).to be_failure
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
expect(err).to match(/freeze \nby running `bundle config unset deployment`./m)
expect(err).to match(/freeze \nby running `bundle config set frozen false`./m)
end

it "should suggest different command when frozen is set globally", :bundler => "< 3" do
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 deployment mode after changing.your Gemfile/m).
and match(/freeze \nby running `bundle config unset frozen`./m)
and match(/freeze \nby running `bundle config set frozen false`./m)
end

it "should suggest different command when frozen is set globally", :bundler => "3" do
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 deployment mode after changing.your Gemfile/m).
and match(/freeze \nby running `bundle config unset deployment`./m)
and match(/freeze \nby running `bundle config set frozen false`./m)
end

it "should not suggest any command to unfreeze bundler if frozen is set through ENV" do
Expand Down