From 4d263d5087c3ccf54649ac2a10ba96cd0245e7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 23 Dec 2019 22:19:31 +0100 Subject: Unify deployment setting and flag Previously, we were recommending `bundle config deployment true; bundle install` as an alternative to `bundle install --deployment`, but they were not working equally. --- lib/bundler/cli/install.rb | 5 +++-- spec/commands/outdated_spec.rb | 2 +- spec/commands/update_spec.rb | 2 +- spec/install/deploy_spec.rb | 15 ++++++++++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index d823fb632f..ecd474971d 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -38,7 +38,8 @@ module Bundler if Bundler.feature_flag.deployment_means_frozen? Bundler.settings.set_command_option :deployment, true else - Bundler.settings.set_command_option :frozen, true + Bundler.settings.set_command_option :deployment, true if options[:deployment] + Bundler.settings.set_command_option :frozen, true if options[:frozen] end end @@ -169,7 +170,7 @@ module Bundler def normalize_settings Bundler.settings.set_command_option :path, nil if options[:system] Bundler.settings.temporary(:path_relative_to_cwd => false) do - Bundler.settings.set_command_option :path, "vendor/bundle" if options[:deployment] + Bundler.settings.set_command_option :path, "vendor/bundle" if Bundler.settings[:deployment] && Bundler.settings[:path].nil? end Bundler.settings.set_command_option_if_given :path, options[:path] Bundler.settings.temporary(:path_relative_to_cwd => false) do diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index 5096688d00..c5d028ae9d 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -553,7 +553,7 @@ RSpec.describe "bundle outdated" do expect(err).to include("You are trying to check outdated gems in deployment mode.") expect(err).to include("Run `bundle outdated` elsewhere.") expect(err).to include("If this is a development machine, remove the ") - expect(err).to include("Gemfile freeze\nby running `bundle install --no-deployment`.") + expect(err).to include("Gemfile freeze\nby running `bundle config unset deployment`.") end end diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index a0c7e33299..e4449312eb 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -286,7 +286,7 @@ RSpec.describe "bundle update" do 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 install --no-deployment`./m) + expect(err).to match(/freeze \nby running `bundle config unset deployment`./m) end it "should suggest different command when frozen is set globally", :bundler => "< 3" do diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb index f31257fac3..f92a531bf5 100644 --- a/spec/install/deploy_spec.rb +++ b/spec/install/deploy_spec.rb @@ -106,7 +106,7 @@ RSpec.describe "install with --deployment or --frozen" do context "when replacing a host with the same host with credentials" do before do - bundle! "install" + bundle! "install", forgotten_command_line_options(:path => "vendor/bundle") gemfile <<-G source "http://user_name:password@localgemserver.test/" gem "rack" @@ -278,6 +278,19 @@ RSpec.describe "install with --deployment or --frozen" do expect(err).not_to include("You have changed in the Gemfile") end + it "installs gems by default to vendor/bundle when `--deployment` is set via an environment variable", :bundler => "< 3" do + ENV["BUNDLE_DEPLOYMENT"] = "true" + bundle "install" + expect(out).to include("vendor/bundle") + end + + it "installs gems to custom path when deployment mode is set via an environment variable ", :bundler => "< 3" do + ENV["BUNDLE_DEPLOYMENT"] = "true" + ENV["BUNDLE_PATH"] = "vendor/bundle2" + bundle "install" + expect(out).to include("vendor/bundle2") + end + it "can have --frozen set to false via an environment variable" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" -- cgit v1.2.1