diff --git a/lib/bundler.rb b/lib/bundler.rb index bc28b24e2ee381..f4f9891247a7c6 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -346,13 +346,13 @@ def original_env # @deprecated Use `unbundled_env` instead def clean_env - Bundler::SharedHelpers.major_deprecation( - 2, + message = "`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \ - "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`", - :print_caller_location => true - ) - + "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`" + removed_message = + "`Bundler.clean_env` has been removed in favor of `Bundler.unbundled_env`. " \ + "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`" + Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true) unbundled_env end @@ -389,13 +389,13 @@ def with_original_env # @deprecated Use `with_unbundled_env` instead def with_clean_env - Bundler::SharedHelpers.major_deprecation( - 2, + message = "`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \ - "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`", - :print_caller_location => true - ) - + "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`" + removed_message = + "`Bundler.with_clean_env` has been removed in favor of `Bundler.with_unbundled_env`. " \ + "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`" + Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true) with_env(unbundled_env) { yield } end @@ -411,13 +411,13 @@ def original_system(*args) # @deprecated Use `unbundled_system` instead def clean_system(*args) - Bundler::SharedHelpers.major_deprecation( - 2, + message = "`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \ - "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`", - :print_caller_location => true - ) - + "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`" + removed_message = + "`Bundler.clean_system` has been removed in favor of `Bundler.unbundled_system`. " \ + "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`" + Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true) with_env(unbundled_env) { Kernel.system(*args) } end @@ -433,13 +433,13 @@ def original_exec(*args) # @deprecated Use `unbundled_exec` instead def clean_exec(*args) - Bundler::SharedHelpers.major_deprecation( - 2, + message = "`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \ - "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`", - :print_caller_location => true - ) - + "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`" + removed_message = + "`Bundler.clean_exec` has been removed in favor of `Bundler.unbundled_exec`. " \ + "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`" + Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true) with_env(unbundled_env) { Kernel.exec(*args) } end diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index c2fa92d875dc0a..f90ddf414709b8 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -190,7 +190,12 @@ def check method_option "install", :type => :boolean, :banner => "Runs 'bundle install' after removing the gems from the Gemfile" def remove(*gems) - SharedHelpers.major_deprecation(2, "The `--install` flag has been deprecated. `bundle install` is triggered by default.") if ARGV.include?("--install") + if ARGV.include?("--install") + message = "The `--install` flag has been deprecated. `bundle install` is triggered by default." + removed_message = "The `--install` flag has been removed. `bundle install` is triggered by default." + SharedHelpers.major_deprecation(2, message, :removed_message => removed_message) + end + require_relative "cli/remove" Remove.new(gems, options).run end @@ -324,7 +329,11 @@ def update(*gems) method_option "outdated", :type => :boolean, :banner => "Show verbose output including whether gems are outdated." def show(gem_name = nil) - SharedHelpers.major_deprecation(2, "the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement") if ARGV.include?("--outdated") + if ARGV.include?("--outdated") + message = "the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement" + removed_message = "the `--outdated` flag to `bundle show` was undocumented and has been removed without replacement" + SharedHelpers.major_deprecation(2, message, :removed_message => removed_message) + end require_relative "cli/show" Show.new(options, gem_name).run end @@ -462,11 +471,18 @@ def fund def cache print_remembered_flag_deprecation("--all", "cache_all", "true") if ARGV.include?("--all") - SharedHelpers.major_deprecation 2, - "The `--path` flag is deprecated because its semantics are unclear. " \ - "Use `bundle config cache_path` to configure the path of your cache of gems, " \ - "and `bundle config path` to configure the path where your gems are installed, " \ - "and stop using this flag" if ARGV.include?("--path") + if ARGV.include?("--path") + message = + "The `--path` flag is deprecated because its semantics are unclear. " \ + "Use `bundle config cache_path` to configure the path of your cache of gems, " \ + "and `bundle config path` to configure the path where your gems are installed, " \ + "and stop using this flag" + removed_message = + "The `--path` flag has been removed because its semantics were unclear. " \ + "Use `bundle config cache_path` to configure the path of your cache of gems, " \ + "and `bundle config path` to configure the path where your gems are installed." + SharedHelpers.major_deprecation 2, message, :removed_message => removed_message + end require_relative "cli/cache" Cache.new(options).run @@ -484,7 +500,9 @@ def cache D def exec(*args) if ARGV.include?("--no-keep-file-descriptors") - SharedHelpers.major_deprecation(2, "The `--no-keep-file-descriptors` has been deprecated. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to") + message = "The `--no-keep-file-descriptors` has been deprecated. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to" + removed_message = "The `--no-keep-file-descriptors` has been removed. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to" + SharedHelpers.major_deprecation(2, message, :removed_message => removed_message) end require_relative "cli/exec" @@ -763,7 +781,9 @@ def self.check_deprecated_ext_option(arguments) # when deprecated version of `--ext` is called # print out deprecation warning and pretend `--ext=c` was provided if deprecated_ext_value?(arguments) - SharedHelpers.major_deprecation 2, "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been deprecated. Please select a language, e.g. `--ext=rust` to generate a Rust extension. This gem will now be generated as if `--ext=c` was used." + message = "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been deprecated. Please select a language, e.g. `--ext=rust` to generate a Rust extension. This gem will now be generated as if `--ext=c` was used." + removed_message = "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been removed. Please select a language, e.g. `--ext=rust` to generate a Rust extension." + SharedHelpers.major_deprecation 2, message, :removed_message => removed_message arguments[arguments.index("--ext")] = "--ext=c" end end @@ -888,11 +908,17 @@ def flag_deprecation(name, flag_name, option) end def print_remembered_flag_deprecation(flag_name, option_name, option_value) - Bundler::SharedHelpers.major_deprecation 2, + message = "The `#{flag_name}` flag is deprecated because it relies on being " \ "remembered across bundler invocations, which bundler will no longer " \ "do in future versions. Instead please use `bundle config set #{option_name} " \ "#{option_value}`, and stop using this flag" + removed_message = + "The `#{flag_name}` flag has been removed because it relied on being " \ + "remembered across bundler invocations, which bundler will no longer " \ + "do. Instead please use `bundle config set #{option_name} " \ + "#{option_value}`, and stop using this flag" + Bundler::SharedHelpers.major_deprecation 2, message, :removed_message => removed_message end end end diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb index e1222c75dd2a22..30b22cf2d5653f 100644 --- a/lib/bundler/cli/config.rb +++ b/lib/bundler/cli/config.rb @@ -25,8 +25,9 @@ def base(name = nil, *value) ["config", "get", ARGV[1]] end - SharedHelpers.major_deprecation 3, - "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead." + message = "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead." + removed_message = "Using the `config` command without a subcommand [list, get, set, unset] is has been removed. Use `bundle #{new_args.join(" ")}` instead." + SharedHelpers.major_deprecation 3, message, :removed_message => removed_message Base.new(options, name, value, self).run end diff --git a/lib/bundler/cli/console.rb b/lib/bundler/cli/console.rb index 1eb8ea82545126..a3891723f989ae 100644 --- a/lib/bundler/cli/console.rb +++ b/lib/bundler/cli/console.rb @@ -9,8 +9,9 @@ def initialize(options, group) end def run - Bundler::SharedHelpers.major_deprecation 2, "bundle console will be replaced " \ - "by `bin/console` generated by `bundle gem `" + message = "bundle console will be replaced by `bin/console` generated by `bundle gem `" + removed_message = "bundle console has been replaced by `bin/console` generated by `bundle gem `" + Bundler::SharedHelpers.major_deprecation 2, message, :removed_message => removed_message group ? Bundler.require(:default, *group.split(" ").map!(&:to_sym)) : Bundler.require ARGV.clear diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index fb064ed7023506..aef45d19e1b157 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -380,15 +380,20 @@ def ask_and_set_linter def deprecated_rubocop_option if !options[:rubocop].nil? if options[:rubocop] - Bundler::SharedHelpers.major_deprecation 2, "--rubocop is deprecated, use --linter=rubocop" + Bundler::SharedHelpers.major_deprecation 2, + "--rubocop is deprecated, use --linter=rubocop", + :removed_message => "--rubocop has been removed, use --linter=rubocop" "rubocop" else - Bundler::SharedHelpers.major_deprecation 2, "--no-rubocop is deprecated, use --linter" + Bundler::SharedHelpers.major_deprecation 2, + "--no-rubocop is deprecated, use --linter", + :removed_message => "--no-rubocop has been removed, use --linter" false end elsif !Bundler.settings["gem.rubocop"].nil? Bundler::SharedHelpers.major_deprecation 2, - "config gem.rubocop is deprecated; we've updated your config to use gem.linter instead" + "config gem.rubocop is deprecated; we've updated your config to use gem.linter instead", + :removed_message => "config gem.rubocop has been removed; we've updated your config to use gem.linter instead" Bundler.settings["gem.rubocop"] ? "rubocop" : false end end diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index f7228db6232fab..c7d287e45f1974 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -51,7 +51,8 @@ def run if options["binstubs"] Bundler::SharedHelpers.major_deprecation 2, - "The --binstubs option will be removed in favor of `bundle binstubs --all`" + "The --binstubs option will be removed in favor of `bundle binstubs --all`", + :removed_message => "The --binstubs option have been removed in favor of `bundle binstubs --all`" end Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins? diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index db59e1a3729f11..f3968d8a6e1338 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -427,9 +427,13 @@ def validate_keys(command, opts, valid_keys) def normalize_source(source) case source when :gemcutter, :rubygems, :rubyforge - Bundler::SharedHelpers.major_deprecation 2, "The source :#{source} is deprecated because HTTP " \ - "requests are insecure.\nPlease change your source to 'https://" \ - "rubygems.org' if possible, or 'http://rubygems.org' if not." + message = + "The source :#{source} is deprecated because HTTP requests are insecure.\n" \ + "Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not." + removed_message = + "The source :#{source} is disallowed because HTTP requests are insecure.\n" \ + "Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not." + Bundler::SharedHelpers.major_deprecation 2, message, :removed_message => removed_message "http://rubygems.org" when String source @@ -474,10 +478,17 @@ def multiple_global_source_warning "should come from that source" raise GemfileEvalError, msg else - Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple global sources. " \ + message = + "Your Gemfile contains multiple global sources. " \ "Using `source` more than once without a block is a security risk, and " \ "may result in installing unexpected gems. To resolve this warning, use " \ "a block to indicate which gems should come from the secondary source." + removed_message = + "Your Gemfile contains multiple global sources. " \ + "Using `source` more than once without a block is a security risk, and " \ + "may result in installing unexpected gems. To resolve this error, use " \ + "a block to indicate which gems should come from the secondary source." + Bundler::SharedHelpers.major_deprecation 2, message, :removed_message => removed_message end end