From 19d931b50d1799fcaeb4da06d9159610272dbb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 15 Jul 2025 21:09:51 +0200 Subject: [PATCH] [rubygems/rubygems] Fix `bundle cache path=foo` not printing a deprecation message https://github.com/rubygems/rubygems/commit/0af03eea5d --- lib/bundler/cli.rb | 10 +++++---- spec/bundler/other/major_deprecation_spec.rb | 22 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 0ccd58e179..f2a3faf6de 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -414,7 +414,7 @@ module Bundler def cache print_remembered_flag_deprecation("--all", "cache_all", "true") if ARGV.include?("--all") - if ARGV.include?("--path") + if flag_passed?("--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, " \ @@ -747,9 +747,7 @@ module Bundler option = current_command.options[name] flag_name = option.switch_name flag_name = "--no-" + flag_name.gsub(/\A--/, "") if negative - - name_index = ARGV.find {|arg| flag_name == arg.split("=")[0] } - return unless name_index + return unless flag_passed?(flag_name) value = options[name] value = value.join(" ").to_s if option.type == :array @@ -771,5 +769,9 @@ module Bundler "#{option_value}`, and stop using this flag" Bundler::SharedHelpers.major_deprecation 2, message, removed_message: removed_message end + + def flag_passed?(name) + ARGV.any? {|arg| name == arg.split("=")[0] } + end end end diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb index a0a1958244..b3d7442f53 100644 --- a/spec/bundler/other/major_deprecation_spec.rb +++ b/spec/bundler/other/major_deprecation_spec.rb @@ -199,6 +199,28 @@ RSpec.describe "major deprecations" do pending "fails with a helpful error", bundler: "4" end + context "bundle cache --path=" do + before do + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack" + G + + bundle "cache --path=foo", raise_on_error: false + end + + it "should print a deprecation warning" do + expect(deprecations).to include( + "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" + ) + end + + pending "fails with a helpful error", bundler: "4" + end + describe "bundle config" do describe "old list interface" do before do