diff options
author | Stefan Sedich <stefan.sedich@gmail.com> | 2017-07-12 15:09:17 -0700 |
---|---|---|
committer | Stefan Sedich <stefan.sedich@gmail.com> | 2017-07-12 15:09:17 -0700 |
commit | 3e9dd31f0afa87b4658abab2f85ee237e7d5cac8 (patch) | |
tree | 07ccd5c2922e0d1cb351b01471c562ea32853880 | |
parent | 6760af8ac03fd0569e2eee1b2808232d51036cac (diff) | |
parent | 6e09ffdb2aab101c454dc51c65b1ee13fb9b503a (diff) | |
download | bundler-3e9dd31f0afa87b4658abab2f85ee237e7d5cac8.tar.gz |
Merge branch 'master' of https://github.com/bundler/bundler into add-process-lock
-rw-r--r-- | lib/bundler.rb | 6 | ||||
-rw-r--r-- | lib/bundler/cli/check.rb | 2 | ||||
-rw-r--r-- | lib/bundler/cli/install.rb | 16 | ||||
-rw-r--r-- | lib/bundler/cli/outdated.rb | 18 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 22 | ||||
-rw-r--r-- | lib/bundler/feature_flag.rb | 1 | ||||
-rw-r--r-- | lib/bundler/injector.rb | 46 | ||||
-rw-r--r-- | lib/bundler/installer.rb | 4 | ||||
-rw-r--r-- | lib/bundler/installer/parallel_installer.rb | 7 | ||||
-rw-r--r-- | lib/bundler/runtime.rb | 2 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 2 | ||||
-rw-r--r-- | man/bundle-config.ronn | 8 | ||||
-rw-r--r-- | spec/bundler/lockfile_parser_spec.rb | 59 | ||||
-rw-r--r-- | spec/bundler/settings_spec.rb | 16 | ||||
-rw-r--r-- | spec/commands/add_spec.rb | 2 | ||||
-rw-r--r-- | spec/commands/check_spec.rb | 8 | ||||
-rw-r--r-- | spec/commands/inject_spec.rb | 8 | ||||
-rw-r--r-- | spec/commands/outdated_spec.rb | 27 | ||||
-rw-r--r-- | spec/commands/package_spec.rb | 3 | ||||
-rw-r--r-- | spec/commands/update_spec.rb | 15 | ||||
-rw-r--r-- | spec/install/deploy_spec.rb | 23 | ||||
-rw-r--r-- | spec/quality_spec.rb | 1 |
22 files changed, 233 insertions, 63 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 9baa5fd788..f38fa0bf5a 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -131,6 +131,12 @@ module Bundler end end + def frozen? + frozen = settings[:deployment] + frozen ||= settings[:frozen] unless feature_flag.deployment_means_frozen? + frozen + end + def locked_gems @locked_gems ||= if defined?(@definition) && @definition diff --git a/lib/bundler/cli/check.rb b/lib/bundler/cli/check.rb index 057a7e5695..96781b6c3a 100644 --- a/lib/bundler/cli/check.rb +++ b/lib/bundler/cli/check.rb @@ -28,7 +28,7 @@ module Bundler not_installed.each {|s| Bundler.ui.error " * #{s.name} (#{s.version})" } Bundler.ui.warn "Install missing gems with `bundle install`" exit 1 - elsif !Bundler.default_lockfile.file? && Bundler.settings[:frozen] + elsif !Bundler.default_lockfile.file? && Bundler.frozen? Bundler.ui.error "This bundle has been frozen, but there is no #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} present" exit 1 else diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 0592385e23..35a0aa7b58 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -32,17 +32,23 @@ module Bundler check_trust_policy - if options[:deployment] || options[:frozen] + if options[:deployment] || options[:frozen] || Bundler.frozen? unless Bundler.default_lockfile.exist? - flag = options[:deployment] ? "--deployment" : "--frozen" - raise ProductionError, "The #{flag} flag requires a #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}. Please make " \ + flag = "--deployment flag" if options[:deployment] + flag ||= "--frozen flag" if options[:frozen] + flag ||= "deployment setting" + raise ProductionError, "The #{flag} requires a #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}. Please make " \ "sure you have checked your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} into version control " \ "before deploying." end options[:local] = true if Bundler.app_cache.exist? - Bundler.settings[:frozen] = "1" + if Bundler.feature_flag.deployment_means_frozen? + Bundler.settings.temporary(:deployment => true) + else + Bundler.settings[:frozen] ||= true + end end # When install is called with --no-deployment, disable deployment mode @@ -66,7 +72,7 @@ module Bundler definition.validate_runtime! installer = Installer.install(Bundler.root, definition, options) - Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.settings[:frozen] + Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen? Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}." Bundler::CLI::Common.output_without_groups_message diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 62cfc3d28c..07e17df981 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -214,13 +214,19 @@ module Bundler end def check_for_deployment_mode - if Bundler.settings[:frozen] - raise ProductionError, "You are trying to check outdated gems in " \ - "deployment mode. Run `bundle outdated` elsewhere.\n" \ - "\nIf this is a development machine, remove the " \ - "#{Bundler.default_gemfile} freeze" \ - "\nby running `bundle install --no-deployment`." + return unless Bundler.frozen? + suggested_command = if Bundler.settings.locations("frozen")[:global] + "bundle config --delete frozen" + elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any? + "bundle config --delete deployment" + else + "bundle install --no-deployment" end + raise ProductionError, "You are trying to check outdated gems in " \ + "deployment mode. Run `bundle outdated` elsewhere.\n" \ + "\nIf this is a development machine, remove the " \ + "#{Bundler.default_gemfile} freeze" \ + "\nby running `#{suggested_command}`." end def update_present_via_semver_portions(current_spec, active_spec, options) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index bf0316b8d8..23b61ffd01 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -102,7 +102,7 @@ module Bundler end @unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version) - add_current_platform unless Bundler.settings[:frozen] + add_current_platform unless Bundler.frozen? converge_path_sources_to_gemspec_sources @path_changes = converge_paths @@ -234,7 +234,10 @@ module Bundler def resolve @resolve ||= begin last_resolve = converge_locked_specs - if Bundler.settings[:frozen] || (!unlocking? && nothing_changed?) + if Bundler.frozen? + Bundler.ui.debug "Frozen, using resolution from the lockfile" + last_resolve + elsif !unlocking? && nothing_changed? Bundler.ui.debug("Found no changes, using resolution from the lockfile") last_resolve else @@ -319,10 +322,10 @@ module Bundler end end - preserve_unknown_sections ||= !updating_major && (Bundler.settings[:frozen] || !unlocking?) + preserve_unknown_sections ||= !updating_major && (Bundler.frozen? || !unlocking?) return if lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections) - if Bundler.settings[:frozen] + if Bundler.frozen? Bundler.ui.error "Cannot write a changed lockfile while frozen." return end @@ -373,8 +376,13 @@ module Bundler "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control." unless explicit_flag - - suggested_command = Bundler.settings.locations("frozen")[:global] == "1" ? "bundle config --delete frozen" : "bundle install --no-deployment" + suggested_command = if Bundler.settings.locations("frozen")[:global] + "bundle config --delete frozen" + elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any? + "bundle config --delete deployment" + else + "bundle install --no-deployment" + end msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \ "freeze \nby running `#{suggested_command}`." end @@ -660,7 +668,7 @@ module Bundler end def converge_dependencies - frozen = Bundler.settings[:frozen] + frozen = Bundler.frozen? (@dependencies + @locked_deps.values).each do |dep| locked_source = @locked_deps[dep.name] # This is to make sure that if bundler is installing in deployment mode and diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index c8c5894c96..2d054c2856 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -30,6 +30,7 @@ module Bundler settings_flag(:allow_offline_install) { bundler_2_mode? } settings_flag(:cache_command_is_package) { bundler_2_mode? } settings_flag(:console_command) { !bundler_2_mode? } + settings_flag(:deployment_means_frozen) { bundler_2_mode? } settings_flag(:disable_multisource) { bundler_2_mode? } settings_flag(:error_on_stderr) { bundler_2_mode? } settings_flag(:global_gem_cache) { bundler_2_mode? } diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb index cba1b3d5e5..d0cece2869 100644 --- a/lib/bundler/injector.rb +++ b/lib/bundler/injector.rb @@ -12,38 +12,40 @@ module Bundler end def inject(gemfile_path, lockfile_path) - if Bundler.settings[:frozen] + if Bundler.frozen? # ensure the lock and Gemfile are synced Bundler.definition.ensure_equivalent_gemfile_and_lockfile(true) - # temporarily remove frozen while we inject - frozen = Bundler.settings.delete(:frozen) end - # evaluate the Gemfile we have now - builder = Dsl.new - builder.eval_gemfile(gemfile_path) + # temporarily unfreeze + Bundler.settings.temporary(:deployment => false, :frozen => false) do + # evaluate the Gemfile we have now + builder = Dsl.new + builder.eval_gemfile(gemfile_path) - # don't inject any gems that are already in the Gemfile - @new_deps -= builder.dependencies + # don't inject any gems that are already in the Gemfile + @new_deps -= builder.dependencies - # add new deps to the end of the in-memory Gemfile - # Set conservative versioining to false because we want to let the resolver resolve the version first - builder.eval_gemfile("injected gems", build_gem_lines(false)) if @new_deps.any? + # add new deps to the end of the in-memory Gemfile + # Set conservative versioning to false because we want to let the resolver resolve the version first + builder.eval_gemfile("injected gems", build_gem_lines(false)) if @new_deps.any? - # resolve to see if the new deps broke anything - @definition = builder.to_definition(lockfile_path, {}) - @definition.resolve_remotely! + # resolve to see if the new deps broke anything + @definition = builder.to_definition(lockfile_path, {}) + @definition.resolve_remotely! - # since nothing broke, we can add those gems to the gemfile - append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @new_deps.any? + # since nothing broke, we can add those gems to the gemfile + append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @new_deps.any? - # since we resolved successfully, write out the lockfile - @definition.lock(Bundler.default_lockfile) + # since we resolved successfully, write out the lockfile + @definition.lock(Bundler.default_lockfile) - # return an array of the deps that we added - return @new_deps - ensure - Bundler.settings[:frozen] = "1" if frozen + # invalidate the cached Bundler.definition + Bundler.reset_paths! + + # return an array of the deps that we added + @new_deps + end end private diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index cbd5b6ec20..cd54320199 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -69,7 +69,7 @@ module Bundler create_bundle_path ProcessLock.lock do - if Bundler.settings[:frozen] + if Bundler.frozen? @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment]) end @@ -84,7 +84,7 @@ module Bundler warn_on_incompatible_bundler_deps install(options) - lock unless Bundler.settings[:frozen] + lock unless Bundler.frozen? Standalone.new(options[:standalone], @definition).generate if options[:standalone] end end diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb index 97c124e015..22bc8c51c6 100644 --- a/lib/bundler/installer/parallel_installer.rb +++ b/lib/bundler/installer/parallel_installer.rb @@ -112,7 +112,12 @@ module Bundler gem_installer = Bundler::GemInstaller.new( spec_install.spec, @installer, @standalone, worker_num, @force ) - success, message = gem_installer.install_from_spec + success, message = begin + gem_installer.install_from_spec + rescue => e + raise e, "#{e}\n\n#{require_tree_for_spec(spec_install.spec)}" + end + if success && !message.nil? spec_install.post_install_message = message elsif !success diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 152471db85..c8f5b8496d 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -11,7 +11,7 @@ module Bundler end def setup(*groups) - @definition.ensure_equivalent_gemfile_and_lockfile if Bundler.settings[:frozen] + @definition.ensure_equivalent_gemfile_and_lockfile if Bundler.frozen? groups.map!(&:to_sym) diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 9bce931734..45934f2944 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -14,6 +14,8 @@ module Bundler cache_all_platforms cache_command_is_package console_command + deployment + deployment_means_frozen disable_checksum_validation disable_exec_load disable_local_branch_check diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn index 1260e9692b..42fb69465a 100644 --- a/man/bundle-config.ronn +++ b/man/bundle-config.ronn @@ -138,6 +138,9 @@ learn more about their operation in [bundle install(1)][bundle-install]. `bundle install`. * `console` (`BUNDLE_CONSOLE`): The console that `bundle console` starts. Defaults to `irb`. +* `deployment` (`BUNDLE_DEPLOYMENT`): + Disallow changes to the `Gemfile`. When the `Gemfile` is changed and the + lockfile has not been updated, running Bundler commands will be blocked. * `disable_checksum_validation` (`BUNDLE_DISABLE_CHECKSUM_VALIDATION`): Allow installing gems even if they do not match the checksum provided by RubyGems. @@ -162,8 +165,9 @@ learn more about their operation in [bundle install(1)][bundle-install]. Ignore the current machine's platform and install only `ruby` platform gems. As a result, gems with native extensions will be compiled from source. * `frozen` (`BUNDLE_FROZEN`): - Disallow changes to the `Gemfile`. Defaults to `true` when `--deployment` - is used. + Disallow changes to the `Gemfile`. When the `Gemfile` is changed and the + lockfile has not been updated, running Bundler commands will be blocked. + Defaults to `true` when `--deployment` is used. * `gem.push_key` (`BUNDLE_GEM__PUSH_KEY`): Sets the `--key` parameter for `gem push` when using the `rake release` command with a private gemstash server. diff --git a/spec/bundler/lockfile_parser_spec.rb b/spec/bundler/lockfile_parser_spec.rb index 37be8d9f66..adf2322742 100644 --- a/spec/bundler/lockfile_parser_spec.rb +++ b/spec/bundler/lockfile_parser_spec.rb @@ -90,4 +90,63 @@ RSpec.describe Bundler::LockfileParser do end end end + + describe "#initialize" do + before { allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app("gems.rb")) } + subject { described_class.new(lockfile_contents) } + + let(:sources) do + [Bundler::Source::Git.new("uri" => "https://github.com/alloy/peiji-san.git", "revision" => "eca485d8dc95f12aaec1a434b49d295c7e91844b"), + Bundler::Source::Rubygems.new("remotes" => ["https://rubygems.org"])] + end + let(:dependencies) do + { + "peiji-san" => Bundler::Dependency.new("peiji-san", ">= 0"), + "rake" => Bundler::Dependency.new("rake", ">= 0"), + } + end + let(:specs) do + [ + Bundler::LazySpecification.new("peiji-san", v("1.2.0"), rb), + Bundler::LazySpecification.new("rake", v("10.3.2"), rb), + ] + end + let(:platforms) { [rb] } + let(:bundler_version) { Gem::Version.new("1.12.0.rc.2") } + let(:ruby_version) { "ruby 2.1.3p242" } + + shared_examples_for "parsing" do + it "parses correctly" do + expect(subject.sources).to eq sources + expect(subject.dependencies).to eq dependencies + expect(subject.specs).to eq specs + expect(Hash[subject.specs.map {|s| [s, s.dependencies] }]).to eq Hash[subject.specs.map {|s| [s, s.dependencies] }] + expect(subject.platforms).to eq platforms + expect(subject.bundler_version).to eq bundler_version + expect(subject.ruby_version).to eq ruby_version + end + end + + include_examples "parsing" + + context "when an extra section is at the end" do + let(:lockfile_contents) { super() + "\n\nFOO BAR\n baz\n baa\n qux\n" } + include_examples "parsing" + end + + context "when an extra section is at the start" do + let(:lockfile_contents) { "FOO BAR\n baz\n baa\n qux\n\n" + super() } + include_examples "parsing" + end + + context "when an extra section is in the middle" do + let(:lockfile_contents) { super().split(/(?=GEM)/).insert(1, "FOO BAR\n baz\n baa\n qux\n\n").join } + include_examples "parsing" + end + + context "when a dependency has options" do + let(:lockfile_contents) { super().sub("peiji-san!", "peiji-san!\n foo: bar") } + include_examples "parsing" + end + end end diff --git a/spec/bundler/settings_spec.rb b/spec/bundler/settings_spec.rb index d680ab3f3e..cdc6745d39 100644 --- a/spec/bundler/settings_spec.rb +++ b/spec/bundler/settings_spec.rb @@ -137,6 +137,22 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow expect(Bundler.settings[:no_install]).to eq true end + + it "returns the return value of the block" do + ret = Bundler.settings.temporary({}) { :ret } + expect(ret).to eq :ret + end + + context "when called without a block" do + it "leaves the setting changed" do + Bundler.settings.temporary(:foo => :random) + expect(Bundler.settings[:foo]).to eq :random + end + + it "returns nil" do + expect(Bundler.settings.temporary(:foo => :bar)).to be_nil + end + end end describe "#set_global" do diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb index aebe8442d1..7916db960a 100644 --- a/spec/commands/add_spec.rb +++ b/spec/commands/add_spec.rb @@ -81,7 +81,7 @@ RSpec.describe "bundle add" do it "using combination of short form options works like long form" do bundle "add 'foo' -s='file://#{gem_repo2}' -g='development' -v='~>1.0'" - expect(bundled_app("Gemfile").read).to match(%r{gem "foo", "~> 1.0", :group => \[:development\], :source => "file:\/\/#{gem_repo2}"}) + expect(bundled_app("Gemfile").read).to include %(gem "foo", "~> 1.0", :group => [:development], :source => "file://#{gem_repo2}") expect(the_bundle).to include_gems "foo 1.1" end diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb index bed9fa1aa9..b16d86e6b6 100644 --- a/spec/commands/check_spec.rb +++ b/spec/commands/check_spec.rb @@ -214,17 +214,17 @@ RSpec.describe "bundle check" do end it "fails when there's no lock file and frozen is set" do - gemfile <<-G + install_gemfile! <<-G source "file://#{gem_repo1}" gem "foo" G - bundle "install" - bundle "install --deployment" + bundle! "config deployment true" + bundle! :install FileUtils.rm(bundled_app("Gemfile.lock")) bundle :check - expect(exitstatus).not_to eq(0) if exitstatus + expect(last_command).to be_failure end context "--path" do diff --git a/spec/commands/inject_spec.rb b/spec/commands/inject_spec.rb index 78f6565d99..80d22ee286 100644 --- a/spec/commands/inject_spec.rb +++ b/spec/commands/inject_spec.rb @@ -79,7 +79,11 @@ Usage: "bundle inject GEM VERSION" context "when frozen" do before do bundle "install" - bundle "config --local frozen 1" + if Bundler.feature_flag.bundler_2_mode? + bundle! "config --local deployment true" + else + bundle! "config --local frozen true" + end end it "injects anyway" do @@ -96,7 +100,7 @@ Usage: "bundle inject GEM VERSION" it "restores frozen afterwards" do bundle "inject 'rack-obama' '> 0'" config = YAML.load(bundled_app(".bundle/config").read) - expect(config["BUNDLE_FROZEN"]).to eq("1") + expect(config["BUNDLE_DEPLOYMENT"] || config["BUNDLE_FROZEN"]).to eq("true") end it "doesn't allow Gemfile changes" do diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index 3ef955fe23..7e2a71e067 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -405,7 +405,7 @@ RSpec.describe "bundle outdated" do expect(out).to include("Installing foo 1.0") end - context "after bundle install --deployment" do + context "after bundle install --deployment", :bundler => "< 2" do before do install_gemfile <<-G, :deployment => true source "file://#{gem_repo2}" @@ -419,7 +419,7 @@ RSpec.describe "bundle outdated" do update_repo2 { build_gem "activesupport", "3.0" } bundle "outdated" - expect(exitstatus).to_not be_zero if exitstatus + expect(last_command).to be_failure expect(out).to include("You are trying to check outdated gems in deployment mode.") expect(out).to include("Run `bundle outdated` elsewhere.") expect(out).to include("If this is a development machine, remove the ") @@ -427,6 +427,29 @@ RSpec.describe "bundle outdated" do end end + context "after bundle config deployment true" do + before do + install_gemfile <<-G + source "file://#{gem_repo2}" + + gem "rack" + gem "foo" + G + bundle! "config deployment true" + end + + it "outputs a helpful message about being in deployment mode" do + update_repo2 { build_gem "activesupport", "3.0" } + + bundle "outdated" + expect(last_command).to be_failure + expect(out).to include("You are trying to check outdated gems in deployment mode.") + expect(out).to include("Run `bundle outdated` elsewhere.") + expect(out).to include("If this is a development machine, remove the ") + expect(out).to include("Gemfile freeze\nby running `bundle config --delete deployment`.") + end + end + context "update available for a gem on a different platform" do before do install_gemfile <<-G diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb index 9b0de7f4e4..d2854f122f 100644 --- a/spec/commands/package_spec.rb +++ b/spec/commands/package_spec.rb @@ -205,6 +205,7 @@ RSpec.describe "bundle package" do subject { bundle "package --frozen" } it "tries to install with frozen" do + bundle! "config deployment true" gemfile <<-G source "file://#{gem_repo1}" gem "rack" @@ -216,7 +217,7 @@ RSpec.describe "bundle package" do expect(out).to include("You have added to the Gemfile") expect(out).to include("* rack-obama") bundle "env" - expect(out).to include("frozen") + expect(out).to include("frozen").or include("deployment") end end end diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index a0f0245046..49a2ceafd1 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -198,7 +198,7 @@ RSpec.describe "bundle update" do end describe "in a frozen bundle" do - it "should fail loudly" do + it "should fail loudly", :bundler => "< 2" do bundle! "install --deployment" bundle "update", :all => bundle_update_requires_all? @@ -207,11 +207,18 @@ RSpec.describe "bundle update" do expect(exitstatus).not_to eq(0) if exitstatus end - it "should suggest different command when frozen is set globally" do + it "should suggest different command when frozen is set globally", :bundler => "< 2" do bundle! "config --global frozen 1" bundle "update", :all => bundle_update_requires_all? - expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m) - expect(out).to match(/freeze \nby running `bundle config --delete frozen`./m) + expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m). + and match(/freeze \nby running `bundle config --delete frozen`./m) + end + + it "should suggest different command when frozen is set globally", :bundler => "2" do + bundle! "config --global deployment true" + bundle "update", :all => bundle_update_requires_all? + expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m). + and match(/freeze \nby running `bundle config --delete deployment`./m) end end diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb index b4ab5d495f..e5a71609ed 100644 --- a/spec/install/deploy_spec.rb +++ b/spec/install/deploy_spec.rb @@ -163,7 +163,7 @@ RSpec.describe "install with --deployment or --frozen" do expect(out).to include("The path `#{lib_path("path_gem-1.0")}` does not exist.") end - it "can have --frozen set via an environment variable" do + it "can have --frozen set via an environment variable", :bundler => "< 2" do gemfile <<-G source "file://#{gem_repo1}" gem "rack" @@ -179,6 +179,22 @@ RSpec.describe "install with --deployment or --frozen" do expect(out).not_to include("You have changed in the Gemfile") end + it "can have --deployment set via an environment variable" do + gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + gem "rack-obama" + G + + ENV["BUNDLE_DEPLOYMENT"] = "true" + bundle "install" + expect(out).to include("deployment mode") + expect(out).to include("You have added to the Gemfile") + expect(out).to include("* rack-obama") + expect(out).not_to include("You have deleted from the Gemfile") + expect(out).not_to include("You have changed in the Gemfile") + end + it "can have --frozen set to false via an environment variable" do gemfile <<-G source "file://#{gem_repo1}" @@ -187,6 +203,7 @@ RSpec.describe "install with --deployment or --frozen" do G ENV["BUNDLE_FROZEN"] = "false" + ENV["BUNDLE_DEPLOYMENT"] = "false" bundle "install" expect(out).not_to include("deployment mode") expect(out).not_to include("You have added to the Gemfile") @@ -277,7 +294,9 @@ RSpec.describe "install with --deployment or --frozen" do end it "remembers that the bundle is frozen at runtime" do - bundle "install --deployment" + bundle! :lock + + bundle! "config deployment true" gemfile <<-G source "file://#{gem_repo1}" diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index 247063b3cf..8c90b33158 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -172,6 +172,7 @@ RSpec.describe "The library itself" do cache_command_is_package console_command default_cli_command + deployment_means_frozen gem.coc gem.mit inline |