Cancel --force deprecation in favor of --redownload

I realized `--redownload` is not a good name, because it does not
necessarily redownloads gems. It only forces reinstallation even if gem
is already installed.

So I believe `--force` is actually a better name and the introduction of
`--force` was a misunderstanding of what the `--force` flag did at the
time.

Let's cancel the deprecation of `--force`.

For now the `--redownload` alias is left around until we decide what to
do with it.
This commit is contained in:
David Rodríguez 2025-07-15 13:35:23 +02:00 committed by Hiroshi SHIBATA
parent 851a3e7724
commit 60fca1defc
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
11 changed files with 54 additions and 92 deletions

View file

@ -220,7 +220,7 @@ module Bundler
method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead" method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
method_option "prefer-local", type: :boolean, banner: "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely" method_option "prefer-local", type: :boolean, banner: "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely"
method_option "no-cache", type: :boolean, banner: "Don't update the existing gem cache." 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." method_option "force", type: :boolean, aliases: "--redownload", banner: "Force reinstalling every gem, even if already installed"
method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache." method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache."
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" unless Bundler.feature_flag.forget_cli_options?}" 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" unless Bundler.feature_flag.forget_cli_options?}"
method_option "quiet", type: :boolean, banner: "Only output warnings and errors." method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
@ -232,8 +232,6 @@ module Bundler
method_option "without", type: :array, banner: "Exclude gems that are part of the specified named group." method_option "without", type: :array, banner: "Exclude gems that are part of the specified named group."
method_option "with", type: :array, banner: "Include gems that are part of the specified named group." method_option "with", type: :array, banner: "Include gems that are part of the specified named group."
def install def install
SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
%w[clean deployment frozen no-prune path shebang without with].each do |option| %w[clean deployment frozen no-prune path shebang without with].each do |option|
remembered_flag_deprecation(option) remembered_flag_deprecation(option)
end end
@ -263,7 +261,7 @@ module Bundler
method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead" method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
method_option "quiet", type: :boolean, banner: "Only output warnings and errors." method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
method_option "source", type: :array, banner: "Update a specific source (and all gems associated with it)" method_option "source", type: :array, banner: "Update a specific source (and all gems associated with it)"
method_option "redownload", type: :boolean, aliases: "--force", banner: "Force downloading every gem." method_option "force", type: :boolean, aliases: "--redownload", banner: "Force reinstalling every gem, even if already installed"
method_option "ruby", type: :boolean, banner: "Update ruby specified in Gemfile.lock" method_option "ruby", type: :boolean, banner: "Update ruby specified in Gemfile.lock"
method_option "bundler", type: :string, lazy_default: "> 0.a", banner: "Update the locked version of bundler" method_option "bundler", type: :string, lazy_default: "> 0.a", banner: "Update the locked version of bundler"
method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version" method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
@ -274,7 +272,6 @@ module Bundler
method_option "conservative", type: :boolean, banner: "Use bundle install conservative update behavior and do not allow shared dependencies to be updated." method_option "conservative", type: :boolean, banner: "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
method_option "all", type: :boolean, banner: "Update everything." method_option "all", type: :boolean, banner: "Update everything."
def update(*gems) def update(*gems)
SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
require_relative "cli/update" require_relative "cli/update"
Bundler.settings.temporary(no_install: false) do Bundler.settings.temporary(no_install: false) do
Update.new(options, gems).run Update.new(options, gems).run

View file

@ -179,7 +179,7 @@ module Bundler
normalize_groups if options[:without] || options[:with] normalize_groups if options[:without] || options[:with]
options[:force] = options[:redownload] options[:force] = options[:redownload] if options[:redownload]
end end
def warn_ambiguous_gems def warn_ambiguous_gems

View file

@ -63,7 +63,7 @@ module Bundler
opts = options.dup opts = options.dup
opts["update"] = true opts["update"] = true
opts["local"] = options[:local] opts["local"] = options[:local]
opts["force"] = options[:redownload] opts["force"] = options[:redownload] if options[:redownload]
Bundler.settings.set_command_option_if_given :jobs, opts["jobs"] Bundler.settings.set_command_option_if_given :jobs, opts["jobs"]

View file

@ -4,7 +4,7 @@
.SH "NAME" .SH "NAME"
\fBbundle\-install\fR \- Install the dependencies specified in your Gemfile \fBbundle\-install\fR \- Install the dependencies specified in your Gemfile
.SH "SYNOPSIS" .SH "SYNOPSIS"
\fBbundle install\fR [\-\-binstubs[=DIRECTORY]] [\-\-clean] [\-\-deployment] [\-\-frozen] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-jobs=NUMBER] [\-\-local] [\-\-no\-cache] [\-\-no\-prune] [\-\-path PATH] [\-\-prefer\-local] [\-\-quiet] [\-\-redownload] [\-\-retry=NUMBER] [\-\-shebang=SHEBANG] [\-\-standalone[=GROUP[ GROUP\|\.\|\.\|\.]]] [\-\-system] [\-\-trust\-policy=TRUST\-POLICY] [\-\-target\-rbconfig=TARGET\-RBCONFIG] [\-\-with=GROUP[ GROUP\|\.\|\.\|\.]] [\-\-without=GROUP[ GROUP\|\.\|\.\|\.]] \fBbundle install\fR [\-\-binstubs[=DIRECTORY]] [\-\-clean] [\-\-deployment] [\-\-force] [\-\-frozen] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-jobs=NUMBER] [\-\-local] [\-\-no\-cache] [\-\-no\-prune] [\-\-path PATH] [\-\-prefer\-local] [\-\-quiet] [\-\-retry=NUMBER] [\-\-shebang=SHEBANG] [\-\-standalone[=GROUP[ GROUP\|\.\|\.\|\.]]] [\-\-system] [\-\-trust\-policy=TRUST\-POLICY] [\-\-target\-rbconfig=TARGET\-RBCONFIG] [\-\-with=GROUP[ GROUP\|\.\|\.\|\.]] [\-\-without=GROUP[ GROUP\|\.\|\.\|\.]]
.SH "DESCRIPTION" .SH "DESCRIPTION"
Install the gems specified in your Gemfile(5)\. If this is the first time you run bundle install (and a \fBGemfile\.lock\fR does not exist), Bundler will fetch all remote sources, resolve dependencies and install all needed gems\. Install the gems specified in your Gemfile(5)\. If this is the first time you run bundle install (and a \fBGemfile\.lock\fR does not exist), Bundler will fetch all remote sources, resolve dependencies and install all needed gems\.
.P .P
@ -29,8 +29,8 @@ In \fIdeployment mode\fR, Bundler will 'roll\-out' the bundle for production or
.IP .IP
This option is deprecated in favor of the \fBdeployment\fR setting\. This option is deprecated in favor of the \fBdeployment\fR setting\.
.TP .TP
\fB\-\-redownload\fR, \fB\-\-force\fR \fB\-\-force\fR, \fB\-\-redownload\fR
Force download every gem, even if the required versions are already available locally\. Force reinstalling every gem, even if already installed\.
.TP .TP
\fB\-\-frozen\fR \fB\-\-frozen\fR
Do not allow the Gemfile\.lock to be updated after this install\. Exits non\-zero if there are going to be changes to the Gemfile\.lock\. Do not allow the Gemfile\.lock to be updated after this install\. Exits non\-zero if there are going to be changes to the Gemfile\.lock\.

View file

@ -6,6 +6,7 @@ bundle-install(1) -- Install the dependencies specified in your Gemfile
`bundle install` [--binstubs[=DIRECTORY]] `bundle install` [--binstubs[=DIRECTORY]]
[--clean] [--clean]
[--deployment] [--deployment]
[--force]
[--frozen] [--frozen]
[--full-index] [--full-index]
[--gemfile=GEMFILE] [--gemfile=GEMFILE]
@ -16,7 +17,6 @@ bundle-install(1) -- Install the dependencies specified in your Gemfile
[--path PATH] [--path PATH]
[--prefer-local] [--prefer-local]
[--quiet] [--quiet]
[--redownload]
[--retry=NUMBER] [--retry=NUMBER]
[--shebang=SHEBANG] [--shebang=SHEBANG]
[--standalone[=GROUP[ GROUP...]]] [--standalone[=GROUP[ GROUP...]]]
@ -80,9 +80,8 @@ automatically and that requires `bundler` to silently remember them. Since
This option is deprecated in favor of the `deployment` setting. This option is deprecated in favor of the `deployment` setting.
* `--redownload`, `--force`: * `--force`, `--redownload`:
Force download every gem, even if the required versions are already available Force reinstalling every gem, even if already installed.
locally.
* `--frozen`: * `--frozen`:
Do not allow the Gemfile.lock to be updated after this install. Exits Do not allow the Gemfile.lock to be updated after this install. Exits

View file

@ -4,7 +4,7 @@
.SH "NAME" .SH "NAME"
\fBbundle\-update\fR \- Update your gems to the latest available versions \fBbundle\-update\fR \- Update your gems to the latest available versions
.SH "SYNOPSIS" .SH "SYNOPSIS"
\fBbundle update\fR \fI*gems\fR [\-\-all] [\-\-group=NAME] [\-\-source=NAME] [\-\-local] [\-\-ruby] [\-\-bundler[=VERSION]] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-jobs=NUMBER] [\-\-quiet] [\-\-patch|\-\-minor|\-\-major] [\-\-pre] [\-\-redownload] [\-\-strict] [\-\-conservative] \fBbundle update\fR \fI*gems\fR [\-\-all] [\-\-group=NAME] [\-\-source=NAME] [\-\-local] [\-\-ruby] [\-\-bundler[=VERSION]] [\-\-force] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-jobs=NUMBER] [\-\-quiet] [\-\-patch|\-\-minor|\-\-major] [\-\-pre] [\-\-strict] [\-\-conservative]
.SH "DESCRIPTION" .SH "DESCRIPTION"
Update the gems specified (all gems, if \fB\-\-all\fR flag is used), ignoring the previously installed gems specified in the \fBGemfile\.lock\fR\. In general, you should use bundle install(1) \fIbundle\-install\.1\.html\fR to install the same exact gems and versions across machines\. Update the gems specified (all gems, if \fB\-\-all\fR flag is used), ignoring the previously installed gems specified in the \fBGemfile\.lock\fR\. In general, you should use bundle install(1) \fIbundle\-install\.1\.html\fR to install the same exact gems and versions across machines\.
.P .P
@ -29,6 +29,9 @@ Update the locked version of Ruby to the current version of Ruby\.
\fB\-\-bundler[=BUNDLER]\fR \fB\-\-bundler[=BUNDLER]\fR
Update the locked version of bundler to the invoked bundler version\. Update the locked version of bundler to the invoked bundler version\.
.TP .TP
\fB\-\-force\fR, \fB\-\-redownload\fR
Force reinstalling every gem, even if already installed\.
.TP
\fB\-\-full\-index\fR \fB\-\-full\-index\fR
Fall back to using the single\-file index of all gems\. Fall back to using the single\-file index of all gems\.
.TP .TP
@ -44,9 +47,6 @@ Retry failed network or git requests for \fInumber\fR times\.
\fB\-\-quiet\fR \fB\-\-quiet\fR
Only output warnings and errors\. Only output warnings and errors\.
.TP .TP
\fB\-\-redownload\fR, \fB\-\-force\fR
Force downloading every gem\.
.TP
\fB\-\-patch\fR \fB\-\-patch\fR
Prefer updating only to next patch version\. Prefer updating only to next patch version\.
.TP .TP

View file

@ -9,13 +9,13 @@ bundle-update(1) -- Update your gems to the latest available versions
[--local] [--local]
[--ruby] [--ruby]
[--bundler[=VERSION]] [--bundler[=VERSION]]
[--force]
[--full-index] [--full-index]
[--gemfile=GEMFILE] [--gemfile=GEMFILE]
[--jobs=NUMBER] [--jobs=NUMBER]
[--quiet] [--quiet]
[--patch|--minor|--major] [--patch|--minor|--major]
[--pre] [--pre]
[--redownload]
[--strict] [--strict]
[--conservative] [--conservative]
@ -54,6 +54,9 @@ gem.
* `--bundler[=BUNDLER]`: * `--bundler[=BUNDLER]`:
Update the locked version of bundler to the invoked bundler version. Update the locked version of bundler to the invoked bundler version.
* `--force`, `--redownload`:
Force reinstalling every gem, even if already installed.
* `--full-index`: * `--full-index`:
Fall back to using the single-file index of all gems. Fall back to using the single-file index of all gems.
@ -70,9 +73,6 @@ gem.
* `--quiet`: * `--quiet`:
Only output warnings and errors. Only output warnings and errors.
* `--redownload`, `--force`:
Force downloading every gem.
* `--patch`: * `--patch`:
Prefer updating only to next patch version. Prefer updating only to next patch version.

View file

@ -1105,7 +1105,7 @@ RSpec.describe "bundle install with gem sources" do
FileUtils.chmod("-x", foo_path) FileUtils.chmod("-x", foo_path)
begin begin
bundle "install --redownload", raise_on_error: false bundle "install --force", raise_on_error: false
ensure ensure
FileUtils.chmod("+x", foo_path) FileUtils.chmod("+x", foo_path)
end end
@ -1141,7 +1141,7 @@ RSpec.describe "bundle install with gem sources" do
FileUtils.chmod("-w", gem_home) FileUtils.chmod("-w", gem_home)
begin begin
bundle "install --redownload" bundle "install --force"
ensure ensure
FileUtils.chmod("+w", gem_home) FileUtils.chmod("+w", gem_home)
end end
@ -1175,7 +1175,7 @@ RSpec.describe "bundle install with gem sources" do
FileUtils.chmod(0o777, gems_path) FileUtils.chmod(0o777, gems_path)
bundle "install --redownload", raise_on_error: false bundle "install --force", raise_on_error: false
expect(err).to include("Bundler cannot reinstall foo-1.0.0 because there's a previous installation of it at #{gems_path}/foo-1.0.0 that is unsafe to remove") expect(err).to include("Bundler cannot reinstall foo-1.0.0 because there's a previous installation of it at #{gems_path}/foo-1.0.0 that is unsafe to remove")
end end

View file

@ -8,7 +8,7 @@ RSpec.describe "bundle install" do
G G
end end
shared_examples_for "an option to force redownloading gems" do shared_examples_for "an option to force reinstalling gems" do
it "re-installs installed gems" do it "re-installs installed gems" do
myrack_lib = default_bundle_path("gems/myrack-1.0.0/lib/myrack.rb") myrack_lib = default_bundle_path("gems/myrack-1.0.0/lib/myrack.rb")
@ -58,34 +58,14 @@ RSpec.describe "bundle install" do
end end
describe "with --force" do describe "with --force" do
it_behaves_like "an option to force redownloading gems" do it_behaves_like "an option to force reinstalling gems" do
let(:flag) { "force" } let(:flag) { "force" }
end end
it "shows a deprecation when single flag passed" do
bundle "install --force"
expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "shows a deprecation when multiple flags passed" do
bundle "install --no-color --force"
expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end end
describe "with --redownload" do describe "with --redownload" do
it_behaves_like "an option to force redownloading gems" do it_behaves_like "an option to force reinstalling gems" do
let(:flag) { "redownload" } let(:flag) { "redownload" }
end end
it "does not show a deprecation when single flag passed" do
bundle "install --redownload"
expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "does not show a deprecation when single multiple flags passed" do
bundle "install --no-color --redownload"
expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end end
end end

View file

@ -0,0 +1,30 @@
# frozen_string_literal: true
RSpec.describe "bundle update" do
before :each do
install_gemfile <<-G
source "https://gem.repo1"
gem "myrack"
G
end
it "re-installs installed gems with --force" do
myrack_lib = default_bundle_path("gems/myrack-1.0.0/lib/myrack.rb")
myrack_lib.open("w") {|f| f.write("blah blah blah") }
bundle :update, force: true
expect(out).to include "Installing myrack 1.0.0"
expect(myrack_lib.open(&:read)).to eq("MYRACK = '1.0.0'\n")
expect(the_bundle).to include_gems "myrack 1.0.0"
end
it "re-installs installed gems with --redownload" do
myrack_lib = default_bundle_path("gems/myrack-1.0.0/lib/myrack.rb")
myrack_lib.open("w") {|f| f.write("blah blah blah") }
bundle :update, redownload: true
expect(out).to include "Installing myrack 1.0.0"
expect(myrack_lib.open(&:read)).to eq("MYRACK = '1.0.0'\n")
expect(the_bundle).to include_gems "myrack 1.0.0"
end
end

View file

@ -1,44 +0,0 @@
# frozen_string_literal: true
RSpec.describe "bundle update" do
before :each do
install_gemfile <<-G
source "https://gem.repo1"
gem "myrack"
G
end
describe "with --force" do
it "shows a deprecation when single flag passed" do
bundle "update myrack --force"
expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "shows a deprecation when multiple flags passed" do
bundle "update myrack --no-color --force"
expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end
describe "with --redownload" do
it "does not show a deprecation when single flag passed" do
bundle "update myrack --redownload"
expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "does not show a deprecation when single multiple flags passed" do
bundle "update myrack --no-color --redownload"
expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "re-installs installed gems" do
myrack_lib = default_bundle_path("gems/myrack-1.0.0/lib/myrack.rb")
myrack_lib.open("w") {|f| f.write("blah blah blah") }
bundle :update, redownload: true
expect(out).to include "Installing myrack 1.0.0"
expect(myrack_lib.open(&:read)).to eq("MYRACK = '1.0.0'\n")
expect(the_bundle).to include_gems "myrack 1.0.0"
end
end
end