Skip to content

Commit 94f6f83

Browse files
Merge pull request #8958 from rubygems/deivid-rodriguez/get-rid-of-remembered-options
Completely remove all remembered CLI flags
2 parents 4fb6122 + 4919e5c commit 94f6f83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+197
-1095
lines changed

bundler/lib/bundler/cli.rb

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def init
173173
D
174174
method_option "dry-run", type: :boolean, default: false, banner: "Lock the Gemfile"
175175
method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
176-
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?}"
176+
method_option "path", type: :string, banner: "Specify a different path than the system default, namely, $BUNDLE_PATH or $GEM_HOME (removed)"
177177
def check
178178
remembered_flag_deprecation("path")
179179

@@ -211,26 +211,26 @@ def remove(*gems)
211211
If the bundle has already been installed, bundler will tell you so and then exit.
212212
D
213213
method_option "binstubs", type: :string, lazy_default: "bin", banner: "Generate bin stubs for bundled gems to ./bin"
214-
method_option "clean", type: :boolean, banner: "Run bundle clean automatically after install"
215-
method_option "deployment", type: :boolean, banner: "Install using defaults tuned for deployment environments"
216-
method_option "frozen", type: :boolean, banner: "Do not allow the Gemfile.lock to be updated after this install"
214+
method_option "clean", type: :boolean, banner: "Run bundle clean automatically after install (removed)"
215+
method_option "deployment", type: :boolean, banner: "Install using defaults tuned for deployment environments (removed)"
216+
method_option "frozen", type: :boolean, banner: "Do not allow the Gemfile.lock to be updated after this install (removed)"
217217
method_option "full-index", type: :boolean, banner: "Fall back to using the single-file index of all gems"
218218
method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
219219
method_option "jobs", aliases: "-j", type: :numeric, banner: "Specify the number of jobs to run in parallel"
220220
method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
221221
method_option "prefer-local", type: :boolean, banner: "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely"
222222
method_option "no-cache", type: :boolean, banner: "Don't update the existing gem cache."
223223
method_option "force", type: :boolean, aliases: "--redownload", banner: "Force reinstalling every gem, even if already installed"
224-
method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache."
225-
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?}"
224+
method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache (removed)."
225+
method_option "path", type: :string, banner: "Specify a different path than the system default, namely, $BUNDLE_PATH or $GEM_HOME (removed)."
226226
method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
227-
method_option "shebang", type: :string, banner: "Specify a different shebang executable name than the default (usually 'ruby')"
227+
method_option "shebang", type: :string, banner: "Specify a different shebang executable name than the default, usually 'ruby' (removed)"
228228
method_option "standalone", type: :array, lazy_default: [], banner: "Make a bundle that can work without the Bundler runtime"
229-
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"
229+
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 (removed)"
230230
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("|")}"
231231
method_option "target-rbconfig", type: :string, banner: "Path to rbconfig.rb for the deployment target platform"
232-
method_option "without", type: :array, banner: "Exclude gems that are part of the specified named group."
233-
method_option "with", type: :array, banner: "Include gems that are part of the specified named group."
232+
method_option "without", type: :array, banner: "Exclude gems that are part of the specified named group (removed)."
233+
method_option "with", type: :array, banner: "Include gems that are part of the specified named group (removed)."
234234
def install
235235
%w[clean deployment frozen no-prune path shebang without with].each do |option|
236236
remembered_flag_deprecation(option)
@@ -323,7 +323,7 @@ def info(gem_name)
323323
will create binstubs for all given gems.
324324
D
325325
method_option "force", type: :boolean, default: false, banner: "Overwrite existing binstubs if they exist"
326-
method_option "path", type: :string, lazy_default: "bin", banner: "Binstub destination directory (default bin)"
326+
method_option "path", type: :string, lazy_default: "bin", banner: "Binstub destination directory, `bin` by default (removed)"
327327
method_option "shebang", type: :string, banner: "Specify a different shebang executable name than the default (usually 'ruby')"
328328
method_option "standalone", type: :boolean, banner: "Make binstubs that can work without the Bundler runtime"
329329
method_option "all", type: :boolean, banner: "Install binstubs for all gems"
@@ -396,15 +396,15 @@ def fund
396396
end
397397

398398
desc "cache [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
399-
method_option "all", type: :boolean, default: Bundler.feature_flag.cache_all?, banner: "Include all sources (including path and git)."
399+
method_option "all", type: :boolean, default: Bundler.settings[:cache_all], banner: "Include all sources (including path and git) (removed)."
400400
method_option "all-platforms", type: :boolean, banner: "Include gems for all platforms present in the lockfile, not only the current one"
401401
method_option "cache-path", type: :string, banner: "Specify a different cache path than the default (vendor/cache)."
402402
method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
403403
method_option "no-install", type: :boolean, banner: "Don't install the gems, only update the cache."
404-
method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache."
405-
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?}"
404+
method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache (removed)."
405+
method_option "path", type: :string, banner: "Specify a different path than the system default, namely, $BUNDLE_PATH or $GEM_HOME (removed)."
406406
method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
407-
method_option "frozen", type: :boolean, banner: "Do not allow the Gemfile.lock to be updated after this bundle cache operation's install"
407+
method_option "frozen", type: :boolean, banner: "Do not allow the Gemfile.lock to be updated after this bundle cache operation's install (removed)"
408408
long_desc <<-D
409409
The cache command will copy the .gem files for every gem in the bundle into the
410410
directory ./vendor/cache. If you then check that directory into your source
@@ -420,16 +420,12 @@ def cache
420420
end
421421

422422
if flag_passed?("--path")
423-
message =
424-
"The `--path` flag is deprecated because its semantics are unclear. " \
425-
"Use `bundle config cache_path` to configure the path of your cache of gems, " \
426-
"and `bundle config path` to configure the path where your gems are installed, " \
427-
"and stop using this flag"
428423
removed_message =
429424
"The `--path` flag has been removed because its semantics were unclear. " \
430425
"Use `bundle config cache_path` to configure the path of your cache of gems, " \
431-
"and `bundle config path` to configure the path where your gems are installed."
432-
SharedHelpers.major_deprecation 2, message, removed_message: removed_message
426+
"and `bundle config path` to configure the path where your gems are installed, " \
427+
"and stop using this flag"
428+
raise InvalidOption, removed_message
433429
end
434430

435431
require_relative "cli/cache"
@@ -749,17 +745,12 @@ def remembered_flag_deprecation(name, negative: false, option_name: nil)
749745
end
750746

751747
def print_remembered_flag_deprecation(flag_name, option_name, option_value)
752-
message =
753-
"The `#{flag_name}` flag is deprecated because it relies on being " \
754-
"remembered across bundler invocations, which bundler will no longer " \
755-
"do in future versions. Instead please use `bundle config set #{option_name} " \
756-
"#{option_value}`, and stop using this flag"
757748
removed_message =
758749
"The `#{flag_name}` flag has been removed because it relied on being " \
759-
"remembered across bundler invocations, which bundler will no longer " \
760-
"do. Instead please use `bundle config set #{option_name} " \
761-
"#{option_value}`, and stop using this flag"
762-
Bundler::SharedHelpers.major_deprecation 2, message, removed_message: removed_message
750+
"remembered across bundler invocations, which bundler no longer does. " \
751+
"Instead please use `bundle config set #{option_name} #{option_value}`, " \
752+
"and stop using this flag"
753+
raise InvalidOption, removed_message
763754
end
764755

765756
def flag_passed?(name)

bundler/lib/bundler/cli/cache.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@ def initialize(options)
1010

1111
def run
1212
Bundler.ui.level = "warn" if options[:quiet]
13-
Bundler.settings.set_command_option_if_given :path, options[:path]
1413
Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"]
1514

16-
setup_cache_all
1715
install
1816

19-
custom_path = Bundler.settings[:path] if options[:path]
20-
2117
Bundler.settings.temporary(cache_all_platforms: options["all-platforms"]) do
22-
Bundler.load.cache(custom_path)
18+
Bundler.load.cache
2319
end
2420
end
2521

@@ -32,11 +28,5 @@ def install
3228
options["no-cache"] = true
3329
Bundler::CLI::Install.new(options).run
3430
end
35-
36-
def setup_cache_all
37-
all = options.fetch(:all, Bundler.feature_flag.cache_all? || nil)
38-
39-
Bundler.settings.set_command_option_if_given :cache_all, all
40-
end
4131
end
4232
end

bundler/lib/bundler/cli/install.rb

Lines changed: 6 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,18 @@ def run
2020

2121
Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Gem.freebsd_platform?
2222

23-
# Disable color in deployment mode
24-
Bundler.ui.shell = Thor::Shell::Basic.new if options[:deployment]
25-
2623
if target_rbconfig_path = options[:"target-rbconfig"]
2724
Bundler.rubygems.set_target_rbconfig(target_rbconfig_path)
2825
end
2926

30-
check_for_options_conflicts
31-
3227
check_trust_policy
3328

34-
if options[:deployment] || options[:frozen] || Bundler.frozen_bundle?
35-
unless Bundler.default_lockfile.exist?
36-
flag = "--deployment flag" if options[:deployment]
37-
flag ||= "--frozen flag" if options[:frozen]
38-
flag ||= "deployment setting" if Bundler.settings[:deployment]
39-
flag ||= "frozen setting" if Bundler.settings[:frozen]
40-
raise ProductionError, "The #{flag} requires a lockfile. Please make " \
41-
"sure you have checked your #{SharedHelpers.relative_lockfile_path} into version control " \
42-
"before deploying."
43-
end
44-
45-
Bundler.settings.set_command_option :deployment, true if options[:deployment]
46-
Bundler.settings.set_command_option :frozen, true if options[:frozen]
47-
end
48-
49-
# When install is called with --no-deployment, disable deployment mode
50-
if options[:deployment] == false
51-
Bundler.settings.set_command_option :frozen, nil
52-
options[:system] = true
29+
if Bundler.frozen_bundle? && !Bundler.default_lockfile.exist?
30+
flag = "deployment setting" if Bundler.settings[:deployment]
31+
flag = "frozen setting" if Bundler.settings[:frozen]
32+
raise ProductionError, "The #{flag} requires a lockfile. Please make " \
33+
"sure you have checked your #{SharedHelpers.relative_lockfile_path} into version control " \
34+
"before deploying."
5335
end
5436

5537
normalize_settings
@@ -118,22 +100,6 @@ def gems_installed_for(definition)
118100
"#{count} #{count == 1 ? "gem" : "gems"} now installed"
119101
end
120102

121-
def check_for_group_conflicts_in_cli_options
122-
conflicting_groups = Array(options[:without]) & Array(options[:with])
123-
return if conflicting_groups.empty?
124-
raise InvalidOption, "You can't list a group in both with and without." \
125-
" The offending groups are: #{conflicting_groups.join(", ")}."
126-
end
127-
128-
def check_for_options_conflicts
129-
if (options[:path] || options[:deployment]) && options[:system]
130-
error_message = String.new
131-
error_message << "You have specified both --path as well as --system. Please choose only one option.\n" if options[:path]
132-
error_message << "You have specified both --deployment as well as --system. Please choose only one option.\n" if options[:deployment]
133-
raise InvalidOption.new(error_message)
134-
end
135-
end
136-
137103
def check_trust_policy
138104
trust_policy = options["trust-policy"]
139105
unless Bundler.rubygems.security_policies.keys.unshift(nil).include?(trust_policy)
@@ -143,28 +109,11 @@ def check_trust_policy
143109
Bundler.settings.set_command_option_if_given :"trust-policy", trust_policy
144110
end
145111

146-
def normalize_groups
147-
check_for_group_conflicts_in_cli_options
148-
149-
# need to nil them out first to get around validation for backwards compatibility
150-
Bundler.settings.set_command_option :without, nil
151-
Bundler.settings.set_command_option :with, nil
152-
Bundler.settings.set_command_option :without, options[:without]
153-
Bundler.settings.set_command_option :with, options[:with]
154-
end
155-
156112
def normalize_settings
157-
Bundler.settings.set_command_option :path, nil if options[:system]
158-
Bundler.settings.set_command_option_if_given :path, options[:path]
159-
160113
if options["standalone"] && Bundler.settings[:path].nil? && !options["local"]
161114
Bundler.settings.set_command_option :path, "bundle"
162115
end
163116

164-
bin_option = options["binstubs"]
165-
bin_option = nil if bin_option&.empty?
166-
Bundler.settings.set_command_option :bin, bin_option if options["binstubs"]
167-
168117
Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
169118

170119
Bundler.settings.set_command_option_if_given :jobs, options["jobs"]
@@ -175,8 +124,6 @@ def normalize_settings
175124

176125
Bundler.settings.set_command_option_if_given :clean, options["clean"]
177126

178-
normalize_groups if options[:without] || options[:with]
179-
180127
options[:force] = options[:redownload] if options[:redownload]
181128
end
182129

bundler/lib/bundler/endpoint_specification.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,6 @@ def load_paths
6060
end
6161
end
6262

63-
# needed for binstubs
64-
def executables
65-
if @remote_specification
66-
@remote_specification.executables
67-
elsif _local_specification
68-
_local_specification.executables
69-
else
70-
super
71-
end
72-
end
73-
74-
# needed for bundle clean
75-
def bindir
76-
if @remote_specification
77-
@remote_specification.bindir
78-
elsif _local_specification
79-
_local_specification.bindir
80-
else
81-
super
82-
end
83-
end
84-
8563
# needed for post_install_messages during install
8664
def post_install_message
8765
if @remote_specification

bundler/lib/bundler/feature_flag.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def self.settings_method(name, key, &default)
2929

3030
settings_flag(:allow_offline_install) { bundler_4_mode? }
3131
settings_flag(:cache_all) { bundler_4_mode? }
32-
settings_flag(:forget_cli_options) { bundler_4_mode? }
3332
settings_flag(:global_gem_cache) { bundler_5_mode? }
3433
settings_flag(:lockfile_checksums) { bundler_4_mode? }
3534
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }

bundler/lib/bundler/installer/gem_installer.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def initialize(spec, installer, standalone = false, worker = 0, force = false, l
1616
def install_from_spec
1717
post_install_message = install
1818
Bundler.ui.debug "#{worker}: #{spec.name} (#{spec.version}) from #{spec.loaded_from}"
19-
generate_executable_stubs
2019
[true, post_install_message]
2120
rescue Bundler::InstallHookError, Bundler::SecurityError, Bundler::APIResponseMismatchError, Bundler::InsecureInstallPathError
2221
raise
@@ -71,15 +70,5 @@ def previous_spec
7170
def out_of_space_message
7271
"#{install_error_message}\nYour disk is out of space. Free some space to be able to install your bundle."
7372
end
74-
75-
def generate_executable_stubs
76-
return if Bundler.feature_flag.forget_cli_options?
77-
return if Bundler.settings[:inline]
78-
if Bundler.settings[:bin] && standalone
79-
installer.generate_standalone_bundler_executable_stubs(spec)
80-
elsif Bundler.settings[:bin]
81-
installer.generate_bundler_executable_stubs(spec, force: true)
82-
end
83-
end
8473
end
8574
end

bundler/lib/bundler/man/bundle-add.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" generated with Ronn-NG/v0.10.1
22
.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3-
.TH "BUNDLE\-ADD" "1" "August 2025" ""
3+
.TH "BUNDLE\-ADD" "1" "September 2025" ""
44
.SH "NAME"
55
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
66
.SH "SYNOPSIS"

bundler/lib/bundler/man/bundle-binstubs.1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
.\" generated with Ronn-NG/v0.10.1
22
.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3-
.TH "BUNDLE\-BINSTUBS" "1" "August 2025" ""
3+
.TH "BUNDLE\-BINSTUBS" "1" "September 2025" ""
44
.SH "NAME"
55
\fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
66
.SH "SYNOPSIS"
7-
\fBbundle binstubs\fR \fIGEM_NAME\fR [\-\-force] [\-\-path PATH] [\-\-standalone] [\-\-all\-platforms]
7+
\fBbundle binstubs\fR \fIGEM_NAME\fR [\-\-force] [\-\-standalone] [\-\-all\-platforms]
88
.SH "DESCRIPTION"
99
Binstubs are scripts that wrap around executables\. Bundler creates a small Ruby file (a binstub) that loads Bundler, runs the command, and puts it into \fBbin/\fR\. Binstubs are a shortcut\-or alternative\- to always using \fBbundle exec\fR\. This gives you a file that can be run directly, and one that will always run the correct gem version used by the application\.
1010
.P
1111
For example, if you run \fBbundle binstubs rspec\-core\fR, Bundler will create the file \fBbin/rspec\fR\. That file will contain enough code to load Bundler, tell it to load the bundled gems, and then run rspec\.
1212
.P
13-
This command generates binstubs for executables in \fBGEM_NAME\fR\. Binstubs are put into \fBbin\fR, or the \fB\-\-path\fR directory if one has been set\. Calling binstubs with [GEM [GEM]] will create binstubs for all given gems\.
13+
This command generates binstubs for executables in \fBGEM_NAME\fR\. Binstubs are put into \fBbin\fR, or the directory specified by \fBbin\fR setting if it has been configured\. Calling binstubs with [GEM [GEM]] will create binstubs for all given gems\.
1414
.SH "OPTIONS"
1515
.TP
1616
\fB\-\-force\fR
1717
Overwrite existing binstubs if they exist\.
1818
.TP
19-
\fB\-\-path[=PATH]\fR
20-
The location to install the specified binstubs to\. This defaults to \fBbin\fR\.
21-
.TP
2219
\fB\-\-standalone\fR
2320
Makes binstubs that can work without depending on Rubygems or Bundler at runtime\.
2421
.TP

0 commit comments

Comments
 (0)