From 11fecfcb051c590b1e4a9eef4db5301e88bb9caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 19 Feb 2019 19:23:19 +0100 Subject: [PATCH 01/10] Teach users how to toggle deprecations off The deprecations will lead to some "true positives" where users will use `bundle config` and remove the flag, and some "false positives" where users will be fine with the option not being remembered but still want to use the flag on a per command basis. Whatever the case, we need to tell users how to get rid of the warning once they learn and get ready for the new behavior. Otherwise it's going to get super annoying! --- lib/bundler/settings.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index ff9a5f57af2..1e866fe7fca 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -119,7 +119,9 @@ def set_command_option(key, value) "flags passed to commands " \ "will no longer be automatically remembered. Instead please set flags " \ "you want remembered between commands using `bundle config set " \ - " `, i.e. `#{command}`" + " `, i.e. `#{command}`. Once you are " \ + "ready for the new behavior, use `bundle config set forget_cli_options " \ + "true` to get rid of this message" set_local(key, value) end From 5c66f4b2722be46488fa8a74afac6255decbb072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 20 Feb 2019 13:15:02 +0100 Subject: [PATCH 02/10] Allow a scape valve to keep the old behavior for now --- lib/bundler/settings.rb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 1e866fe7fca..5a233ac3ae8 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -115,13 +115,19 @@ def set_command_option(key, value) "bundle config set #{key} #{Array(value).join(":")}" end - Bundler::SharedHelpers.major_deprecation 2,\ - "flags passed to commands " \ - "will no longer be automatically remembered. Instead please set flags " \ - "you want remembered between commands using `bundle config set " \ - " `, i.e. `#{command}`. Once you are " \ - "ready for the new behavior, use `bundle config set forget_cli_options " \ - "true` to get rid of this message" + unless Bundler.settings[:forget_cli_options] == false + Bundler::SharedHelpers.major_deprecation 2,\ + "flags passed to commands " \ + "will no longer be automatically remembered. Instead please set flags " \ + "you want remembered between commands using `bundle config set " \ + " `, i.e. `#{command}`. Once you are " \ + "ready for the new behavior, use `bundle config set forget_cli_options " \ + "true` to get rid of this message. Or if you want to get rid of " \ + "this message and stick with the old behavior for now, run " \ + "`bundle config set forget_cli_options false`, but keep in mind " \ + "that this behavior will be fully removed in future versions of " \ + "bundler." + end set_local(key, value) end From aaca317e4d2cea9140e989e6c025936eb4509eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 20 Feb 2019 15:56:01 +0100 Subject: [PATCH 03/10] Delay requiring --all to update everything to bundler 3 Since we haven't even yet deprecated the old behavior. --- lib/bundler/feature_flag.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 0adbd9190f5..4dd104e3b28 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -54,7 +54,7 @@ def self.settings_method(name, key, &default) settings_flag(:specific_platform) { bundler_2_mode? } settings_flag(:suppress_install_using_messages) { bundler_2_mode? } settings_flag(:unlock_source_unlocks_spec) { !bundler_2_mode? } - settings_flag(:update_requires_all_flag) { bundler_2_mode? } + settings_flag(:update_requires_all_flag) { bundler_3_mode? } settings_flag(:use_gem_version_promoter_for_major_updates) { bundler_2_mode? } settings_flag(:viz_command) { !bundler_2_mode? } From 0e64e0d4bf1ded4ad5ee2f241da004bb34b21dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 21 Feb 2019 16:52:23 +0100 Subject: [PATCH 04/10] Remove messy TODO comments Classic problems, comments do not get as curated as code, so they don't currently make sense. --- lib/bundler/dsl.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 6f0d3611605..3af2c94bd9d 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -304,7 +304,6 @@ def add_git_sources # "https://github.com/#{repo_name}.git" # end repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") - # TODO: 2.0 upgrade this setting to the default if Bundler.feature_flag.github_https? Bundler::SharedHelpers.major_deprecation 2, "The `github.https` setting will be removed" "https://github.com/#{repo_name}.git" @@ -313,14 +312,12 @@ def add_git_sources end end - # TODO: 2.0 remove this deprecated git source git_source(:gist) do |repo_name| warn_deprecated_git_source(:gist, '"https://gist.github.com/#{repo_name}.git"') "https://gist.github.com/#{repo_name}.git" end - # TODO: 2.0 remove this deprecated git source git_source(:bitbucket) do |repo_name| warn_deprecated_git_source(:bitbucket, <<-'RUBY'.strip) user_name, repo_name = repo_name.split("/") @@ -488,7 +485,6 @@ def check_primary_source_safety(source_list) end def warn_deprecated_git_source(name, replacement, additional_message = nil) - # TODO: 2.0 remove deprecation additional_message &&= " #{additional_message}" replacement = if replacement.count("\n").zero? "{|repo_name| #{replacement} }" From 1d3b925ddfbaa5d68a133549f6331d34a720159e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 21 Feb 2019 17:28:31 +0100 Subject: [PATCH 05/10] github.https setting is boolean --- lib/bundler/settings.rb | 1 + spec/bundler/dsl_spec.rb | 2 +- spec/quality_spec.rb | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 5a233ac3ae8..d0fb02e77ab 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -35,6 +35,7 @@ class Settings frozen gem.coc gem.mit + github.https global_path_appends_ruby_scope global_gem_cache ignore_messages diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index ce0544a5732..19a5d6bcd1c 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -28,7 +28,7 @@ context "github_https feature flag" do it "is true when github.https is true" do bundle "config set github.https true" - expect(Bundler.feature_flag.github_https?).to eq "true" + expect(Bundler.feature_flag.github_https?).to eq true end end diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index 8bdef33a79f..60de02d5c59 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -172,6 +172,7 @@ def check_for_specific_pronouns(filename) forget_cli_options gem.coc gem.mit + github.https inline lockfile_uses_separate_rubygems_sources use_gem_version_promoter_for_major_updates From c27980152a40c6b9f121fca8ff1816d5d1ff47f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 21 Feb 2019 17:47:36 +0100 Subject: [PATCH 06/10] Remove environmental deprecations Not necessary since no future version will run them. --- spec/other/major_deprecation_spec.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb index ef51112d720..075a92b17cb 100644 --- a/spec/other/major_deprecation_spec.rb +++ b/spec/other/major_deprecation_spec.rb @@ -2,7 +2,6 @@ RSpec.describe "major deprecations", :bundler => "< 2" do let(:warnings) { last_command.bundler_err } # change to err in 2.0 - let(:warnings_without_version_messages) { warnings.gsub(/#{Spec::Matchers::MAJOR_DEPRECATION}Bundler will only support ruby >= .*/, "") } before do create_file "gems.rb", <<-G @@ -35,7 +34,7 @@ describe "bundle update --quiet" do it "does not print any deprecations" do bundle :update, :quiet => true - expect(warnings_without_version_messages).not_to have_major_deprecation + expect(warnings).not_to have_major_deprecation end end @@ -52,7 +51,7 @@ it "does not warn when --all is passed" do bundle! "update --all" - expect(warnings_without_version_messages).not_to have_major_deprecation + expect(warnings).not_to have_major_deprecation end end @@ -76,7 +75,7 @@ G bundle :install - expect(warnings_without_version_messages).not_to have_major_deprecation + expect(warnings).not_to have_major_deprecation end it "should print a Gemfile deprecation warning" do @@ -122,7 +121,7 @@ Bundler.setup RUBY - expect(warnings_without_version_messages).to have_major_deprecation("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.") + expect(warnings).to have_major_deprecation("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.") end end From afbcac5850e74f9e87fc33c23e264378eb1b3172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 21 Feb 2019 17:55:06 +0100 Subject: [PATCH 07/10] Switch gems.rb vs Gemfile warning to only warn about multiple gemfiles It's just too early to deprecate "Gemfile", and I don't think this deprecation was even doing that. --- lib/bundler/shared_helpers.rb | 10 ++++++---- spec/other/major_deprecation_spec.rb | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 996f7b3fd40..cf53c1acbcb 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -157,11 +157,13 @@ def print_major_deprecations! multiple_gemfiles = search_up(".") do |dir| gemfiles = gemfile_names.select {|gf| File.file? File.expand_path(gf, dir) } next if gemfiles.empty? - break false if gemfiles.size == 1 + break gemfiles.size != 1 end - return unless multiple_gemfiles && Bundler.bundler_major_version == 1 - Bundler::SharedHelpers.major_deprecation 2, \ - "gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock." + + return unless multiple_gemfiles + + Bundler.ui.warn \ + "Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler will ignore them." end def trap(signal, override = false, &block) diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb index 075a92b17cb..0d53258b550 100644 --- a/spec/other/major_deprecation_spec.rb +++ b/spec/other/major_deprecation_spec.rb @@ -78,15 +78,15 @@ expect(warnings).not_to have_major_deprecation end - it "should print a Gemfile deprecation warning" do + it "should print a Gemfile deprecation warning when both types present" do create_file "gems.rb" install_gemfile! <<-G source "file://#{gem_repo1}" gem "rack" G - expect(the_bundle).to include_gem "rack 1.0" + expect(the_bundle).not_to include_gem "rack 1.0" - expect(warnings).to have_major_deprecation a_string_including("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.") + expect(warnings).to have_major_deprecation("Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler will ignore them.") end context "with flags" do @@ -121,7 +121,7 @@ Bundler.setup RUBY - expect(warnings).to have_major_deprecation("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.") + expect(warnings).to include("Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler will ignore them.") end end From 0c9592ef27b9ac2523a6fe264e73454c2fd26bb9 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 30 Jan 2019 20:17:52 -0800 Subject: [PATCH 08/10] Actually switch the default behavior of github sources. This fixes #6910. The idea here is that we first switch the default source to https, but not yet deprecate the custom sources, but only making them use http. On bundler 3 we can actually go and deprecate the sources. --- lib/bundler/dsl.rb | 19 +++---------- lib/bundler/feature_flag.rb | 2 +- spec/bundler/dsl_spec.rb | 12 ++++----- spec/other/major_deprecation_spec.rb | 40 +++++++++++++++------------- 4 files changed, 32 insertions(+), 41 deletions(-) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 3af2c94bd9d..a53fd7a26f8 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -290,24 +290,11 @@ def add_git_sources warn_deprecated_git_source(:github, <<-'RUBY'.strip, 'Change any "reponame" :github sources to "username/reponame".') "https://github.com/#{repo_name}.git" RUBY - # It would be better to use https instead of the git protocol, but this - # can break deployment of existing locked bundles when switching between - # different versions of Bundler. The change will be made in 2.0, which - # does not guarantee compatibility with the 1.x series. - # - # See https://github.com/bundler/bundler/pull/2569 for discussion - # - # This can be overridden by adding this code to your Gemfiles: - # - # git_source(:github) do |repo_name| - # repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") - # "https://github.com/#{repo_name}.git" - # end repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") if Bundler.feature_flag.github_https? - Bundler::SharedHelpers.major_deprecation 2, "The `github.https` setting will be removed" "https://github.com/#{repo_name}.git" else + Bundler::SharedHelpers.major_deprecation 2, "Setting `github.https` to false is deprecated and won't be supported in the future." "git://github.com/#{repo_name}.git" end end @@ -492,8 +479,8 @@ def warn_deprecated_git_source(name, replacement, additional_message = nil) "do |repo_name|\n#{replacement.to_s.gsub(/^/, " ")}\n end" end - Bundler::SharedHelpers.major_deprecation 2, <<-EOS -The :#{name} git source is deprecated, and will be removed in Bundler 2.0.#{additional_message} Add this code to the top of your Gemfile to ensure it continues to work: + Bundler::SharedHelpers.major_deprecation 3, <<-EOS +The :#{name} git source is deprecated, and will be removed in Bundler 3.0.#{additional_message} Add this code to the top of your Gemfile to ensure it continues to work: git_source(:#{name}) #{replacement} diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 4dd104e3b28..888b2a1eab5 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -50,7 +50,7 @@ def self.settings_method(name, key, &default) settings_flag(:prefer_gems_rb) { bundler_2_mode? } settings_flag(:print_only_version_number) { bundler_2_mode? } settings_flag(:setup_makes_kernel_gem_public) { !bundler_2_mode? } - settings_flag(:skip_default_git_sources) { bundler_2_mode? } + settings_flag(:skip_default_git_sources) { bundler_3_mode? } settings_flag(:specific_platform) { bundler_2_mode? } settings_flag(:suppress_install_using_messages) { bundler_2_mode? } settings_flag(:unlock_source_unlocks_spec) { !bundler_2_mode? } diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index 19a5d6bcd1c..8d61ef4540a 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -44,7 +44,7 @@ it "converts :github to :git" do subject.gem("sparks", :github => "indirect/sparks") - github_uri = "git://github.com/indirect/sparks.git" + github_uri = "https://github.com/indirect/sparks.git" expect(subject.dependencies.first.source.uri).to eq(github_uri) end @@ -62,7 +62,7 @@ it "converts 'rails' to 'rails/rails'" do subject.gem("rails", :github => "rails") - github_uri = "git://github.com/rails/rails.git" + github_uri = "https://github.com/rails/rails.git" expect(subject.dependencies.first.source.uri).to eq(github_uri) end @@ -79,7 +79,7 @@ end end - context "default git sources", :bundler => "2" do + context "default git sources", :bundler => "3" do it "has none" do expect(subject.instance_variable_get(:@git_sources)).to eq({}) end @@ -245,7 +245,7 @@ # gem 'spree_api' # gem 'spree_backend' # end - describe "#github", :bundler => "< 2" do + describe "#github", :bundler => "< 3" do it "from github" do spree_gems = %w[spree_core spree_api spree_backend] subject.github "spree" do @@ -253,12 +253,12 @@ end subject.dependencies.each do |d| - expect(d.source.uri).to eq("git://github.com/spree/spree.git") + expect(d.source.uri).to eq("https://github.com/spree/spree.git") end end end - describe "#github", :bundler => "2" do + describe "#github", :bundler => "3" do it "from github" do expect do spree_gems = %w[spree_core spree_api spree_backend] diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb index 0d53258b550..113715342d3 100644 --- a/spec/other/major_deprecation_spec.rb +++ b/spec/other/major_deprecation_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "major deprecations", :bundler => "< 2" do +RSpec.describe "major deprecations" do let(:warnings) { last_command.bundler_err } # change to err in 2.0 before do @@ -145,27 +145,31 @@ end context "with github gems" do - it "warns about the https change" do - msg = <<-EOS -The :github git source is deprecated, and will be removed in Bundler 2.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work: + let(:msg) do + <<-EOS +The :github git source is deprecated, and will be removed in Bundler 3.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work: git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" } EOS - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) - subject.gem("sparks", :github => "indirect/sparks") end - it "upgrades to https on request" do - Bundler.settings.temporary "github.https" => true - msg = <<-EOS -The :github git source is deprecated, and will be removed in Bundler 2.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work: + it "warns about future removal" do + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) + subject.gem("sparks", :github => "indirect/sparks") + end - git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" } + it "downgrades to http on request" do + Bundler.settings.temporary "github.https" => false + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, "Setting `github.https` to false is deprecated and won't be supported in the future.") + subject.gem("sparks", :github => "indirect/sparks") + github_uri = "git://github.com/indirect/sparks.git" + expect(subject.dependencies.first.source.uri).to eq(github_uri) + end - EOS - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, "The `github.https` setting will be removed") + it "uses https by default" do + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) subject.gem("sparks", :github => "indirect/sparks") github_uri = "https://github.com/indirect/sparks.git" expect(subject.dependencies.first.source.uri).to eq(github_uri) @@ -176,7 +180,7 @@ it "warns about removal" do allow(Bundler.ui).to receive(:deprecate) msg = <<-EOS -The :bitbucket git source is deprecated, and will be removed in Bundler 2.0. Add this code to the top of your Gemfile to ensure it continues to work: +The :bitbucket git source is deprecated, and will be removed in Bundler 3.0. Add this code to the top of your Gemfile to ensure it continues to work: git_source(:bitbucket) do |repo_name| user_name, repo_name = repo_name.split("/") @@ -185,7 +189,7 @@ end EOS - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails") end end @@ -194,10 +198,10 @@ it "warns about removal" do allow(Bundler.ui).to receive(:deprecate) msg = "The :gist git source is deprecated, and will be removed " \ - "in Bundler 2.0. Add this code to the top of your Gemfile to ensure it " \ + "in Bundler 3.0. Add this code to the top of your Gemfile to ensure it " \ "continues to work:\n\n git_source(:gist) {|repo_name| " \ "\"https://gist.github.com/\#{repo_name}.git\" }\n\n" - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) subject.gem("not-really-a-gem", :gist => "1234") end end From 0b3aeeb7696745b379ee7fbd1b16c2b7ea5b27c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 21 Feb 2019 18:07:08 +0100 Subject: [PATCH 09/10] Deprecate a bunch of flags in bundler 2 Under the previous code, once we stop remembering options, these flags would be automatically removed without deprecation. Instead, first deprecate the options in bundler 2, then remove them and stop remembering them in bundler 3. --- lib/bundler/cli.rb | 51 ++++++++++++++++++---------- lib/bundler/feature_flag.rb | 2 +- lib/bundler/settings.rb | 2 +- spec/other/major_deprecation_spec.rb | 30 +++++++++++++++- 4 files changed, 65 insertions(+), 20 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 916ae9bf782..2d63072299a 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -61,11 +61,6 @@ def initialize(*args) end end - def self.deprecated_option(*args, &blk) - return if Bundler.feature_flag.forget_cli_options? - method_option(*args, &blk) - end - check_unknown_options!(:except => [:config, :exec]) stop_on_unknown_option! :exec @@ -142,7 +137,7 @@ def self.handle_no_command_error(command, has_namespace = $thor_runner) Gemfile to a gem with a gemspec, the --gemspec option will automatically add each dependency listed in the gemspec file to the newly created Gemfile. D - deprecated_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile" + method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile" def init require "bundler/cli/init" Init.new(options.dup).run @@ -188,13 +183,13 @@ def remove(*gems) If the bundle has already been installed, bundler will tell you so and then exit. D - deprecated_option "binstubs", :type => :string, :lazy_default => "bin", :banner => + method_option "binstubs", :type => :string, :lazy_default => "bin", :banner => "Generate bin stubs for bundled gems to ./bin" - deprecated_option "clean", :type => :boolean, :banner => + method_option "clean", :type => :boolean, :banner => "Run bundle clean automatically after install" - deprecated_option "deployment", :type => :boolean, :banner => + method_option "deployment", :type => :boolean, :banner => "Install using defaults tuned for deployment environments" - deprecated_option "frozen", :type => :boolean, :banner => + method_option "frozen", :type => :boolean, :banner => "Do not allow the Gemfile.lock to be updated after this install" method_option "full-index", :type => :boolean, :banner => "Fall back to using the single-file index of all gems" @@ -204,32 +199,37 @@ def remove(*gems) "Specify the number of jobs to run in parallel" method_option "local", :type => :boolean, :banner => "Do not attempt to fetch gems remotely and use the gem cache instead" - deprecated_option "no-cache", :type => :boolean, :banner => + method_option "no-cache", :type => :boolean, :banner => "Don't update the existing gem cache." method_option "redownload", :type => :boolean, :aliases => "--force", :banner => "Force downloading every gem." - deprecated_option "no-prune", :type => :boolean, :banner => + method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache." - deprecated_option "path", :type => :string, :banner => + method_option "path", :type => :string, :banner => "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine" method_option "quiet", :type => :boolean, :banner => "Only output warnings and errors." - deprecated_option "shebang", :type => :string, :banner => + method_option "shebang", :type => :string, :banner => "Specify a different shebang executable name than the default (usually 'ruby')" method_option "standalone", :type => :array, :lazy_default => [], :banner => "Make a bundle that can work without the Bundler runtime" - deprecated_option "system", :type => :boolean, :banner => + method_option "system", :type => :boolean, :banner => "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application" method_option "trust-policy", :alias => "P", :type => :string, :banner => "Gem trust policy (like gem install -P). Must be one of " + Bundler.rubygems.security_policy_keys.join("|") - deprecated_option "without", :type => :array, :banner => + method_option "without", :type => :array, :banner => "Exclude gems that are part of the specified named group." - deprecated_option "with", :type => :array, :banner => + method_option "with", :type => :array, :banner => "Include gems that are part of the specified named group." map "i" => "install" def install SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force") + + %w[clean deployment frozen no-cache no-prune path shebang system without with].each do |option| + remembered_flag_deprecation(option) + end + require "bundler/cli/install" Bundler.settings.temporary(:no_install => false) do Install.new(options.dup).run @@ -786,5 +786,22 @@ def warn_on_outdated_bundler rescue RuntimeError nil end + + def remembered_flag_deprecation(name) + option = current_command.options[name] + flag_name = option.switch_name + + name_index = ARGV.find {|arg| flag_name == arg } + return unless name_index + + value = options[name] + value = "#{value.join(" ")}" if option.type == :array + + Bundler::SharedHelpers.major_deprecation 2,\ + "The `#{flag_name}` flag is deprecated because it relied on being " \ + "remembered accross bundler invokations, which bundler will no longer " \ + "do in future versions. Instead please use `bundle config #{name} " \ + "'#{value}'`, and stop using this flag" + end end end diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 888b2a1eab5..aafd37f7663 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -38,7 +38,7 @@ def self.settings_method(name, key, &default) 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(:forget_cli_options) { bundler_2_mode? } + settings_flag(:forget_cli_options) { bundler_3_mode? } settings_flag(:global_path_appends_ruby_scope) { bundler_2_mode? } settings_flag(:global_gem_cache) { bundler_2_mode? } settings_flag(:init_gems_rb) { bundler_2_mode? } diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index d0fb02e77ab..284b9628336 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -117,7 +117,7 @@ def set_command_option(key, value) end unless Bundler.settings[:forget_cli_options] == false - Bundler::SharedHelpers.major_deprecation 2,\ + Bundler::SharedHelpers.major_deprecation 3,\ "flags passed to commands " \ "will no longer be automatically remembered. Instead please set flags " \ "you want remembered between commands using `bundle config set " \ diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb index 113715342d3..3cf787f05c6 100644 --- a/spec/other/major_deprecation_spec.rb +++ b/spec/other/major_deprecation_spec.rb @@ -90,7 +90,7 @@ end context "with flags" do - it "should print a deprecation warning about autoremembering flags" do + it "should print a deprecation warning about autoremembering flags", :bundler => "3" do install_gemfile <<-G, :path => "vendor/bundle" source "file://#{gem_repo1}" gem "rack" @@ -100,6 +100,34 @@ "flags passed to commands will no longer be automatically remembered." ) end + + { + :clean => true, + :deployment => true, + :frozen => true, + :"no-cache" => true, + :"no-prune" => true, + :path => "vendor/bundle", + :shebang => "ruby27", + :system => true, + :without => "development", + :with => "development", + }.each do |name, value| + flag_name = "--#{name}" + + context "with the #{flag_name} flag" do + it "should print a deprecation warning" do + bundle "install #{flag_name} #{value}" + + expect(warnings).to have_major_deprecation( + "The `#{flag_name}` flag is deprecated because it relied on " \ + "being remembered accross bundler invokations, which bundler " \ + "will no longer do in future versions. Instead please use " \ + "`bundle config #{name} '#{value}'`, and stop using this flag" + ) + end + end + end end end From 7b44d4d74d0c177044be7f8e44e1e1089e0d8980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 21 Feb 2019 18:09:24 +0100 Subject: [PATCH 10/10] Better test description --- spec/other/major_deprecation_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb index 3cf787f05c6..463c907eeae 100644 --- a/spec/other/major_deprecation_spec.rb +++ b/spec/other/major_deprecation_spec.rb @@ -67,7 +67,7 @@ end end - context "when bundle is run" do + context "when bundle install is run" do it "should not warn about gems.rb" do create_file "gems.rb", <<-G source "file://#{gem_repo1}"