Skip to content

Commit

Permalink
Improve suggested unfreeze command
Browse files Browse the repository at this point in the history
Now that frozen can be overridden when deployment is set, we can always
suggest setting that.
  • Loading branch information
deivid-rodriguez committed May 24, 2023
1 parent 6168c12 commit c6c0463
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
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" 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" 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

0 comments on commit c6c0463

Please sign in to comment.