Skip to content

Commit

Permalink
[rubygems/rubygems] Remove weird line breaks in the middle of error m…
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and hsbt committed Jun 14, 2023
1 parent 90c60e8 commit e7749c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
9 changes: 4 additions & 5 deletions lib/bundler/definition.rb
Expand Up @@ -365,16 +365,15 @@ def to_lock

def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
msg = String.new
msg << "You are trying to install in deployment mode after changing\n" \
"your Gemfile. Run `bundle install` elsewhere and add the\n" \
"updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
msg << "You are trying to install in deployment 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 << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
"freeze \nby running `#{suggested_command}`." if suggested_command
msg << "If this is a development machine, remove the #{Bundler.default_gemfile} " \
"freeze by running `#{suggested_command}`." if suggested_command
end

added = []
Expand Down
14 changes: 7 additions & 7 deletions spec/bundler/commands/update_spec.rb
Expand Up @@ -658,27 +658,27 @@
bundle "update", :all => true, :raise_on_error => false

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 set frozen false`./m)
expect(err).to match(/You are trying to install in deployment mode after changing your Gemfile/)
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 deployment mode after changing.your Gemfile/m).
and match(/freeze \nby running `bundle config set frozen false`./m)
expect(err).to match(/You are trying to install in deployment mode after changing your Gemfile/).
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 deployment mode after changing.your Gemfile/m).
and match(/freeze \nby running `bundle config set frozen false`./m)
expect(err).to match(/You are trying to install in deployment mode after changing your Gemfile/).
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 deployment mode after changing.your Gemfile/m)
expect(err).to match(/You are trying to install in deployment mode after changing your Gemfile/)
expect(err).not_to match(/by running/)
end
end
Expand Down

0 comments on commit e7749c4

Please sign in to comment.