[rubygems/rubygems] Fix bundle binstub --path=foo not printing a deprecation warning

Like others, it's a remembered option which we are deprecating in favor
of configuration.

801d5dd943
This commit is contained in:
David Rodríguez 2025-07-15 21:20:01 +02:00 committed by Hiroshi SHIBATA
parent 19d931b50d
commit 44dd27c430
2 changed files with 26 additions and 2 deletions

View file

@ -331,6 +331,8 @@ module Bundler
method_option "all", type: :boolean, banner: "Install binstubs for all gems"
method_option "all-platforms", type: :boolean, default: false, banner: "Install binstubs for all platforms"
def binstubs(*gems)
remembered_flag_deprecation("path", option_name: "bin")
require_relative "cli/binstubs"
Binstubs.new(options, gems).run
end
@ -743,7 +745,7 @@ module Bundler
nil
end
def remembered_flag_deprecation(name, negative: false)
def remembered_flag_deprecation(name, negative: false, option_name: nil)
option = current_command.options[name]
flag_name = option.switch_name
flag_name = "--no-" + flag_name.gsub(/\A--/, "") if negative
@ -753,7 +755,7 @@ module Bundler
value = value.join(" ").to_s if option.type == :array
value = "'#{value}'" unless option.type == :boolean
print_remembered_flag_deprecation(flag_name, name.tr("-", "_"), value)
print_remembered_flag_deprecation(flag_name, option_name || name.tr("-", "_"), value)
end
def print_remembered_flag_deprecation(flag_name, option_name, option_value)

View file

@ -155,6 +155,28 @@ RSpec.describe "major deprecations" do
pending "fails with a helpful error", bundler: "4"
end
context "bundle binstubs --path=" do
before do
install_gemfile <<-G
source "https://gem.repo1"
gem "myrack"
G
bundle "binstubs myrack --path=binpath", raise_on_error: false
end
it "should print a deprecation warning" do
expect(deprecations).to include(
"The `--path` 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 " \
"bin 'binpath'`, and stop using this flag"
)
end
pending "fails with a helpful error", bundler: "4"
end
context "bundle cache --all" do
before do
install_gemfile <<-G