bundler 2.7.2 → 4.0.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +990 -917
  3. data/README.md +4 -4
  4. data/bundler.gemspec +3 -3
  5. data/lib/bundler/build_metadata.rb +2 -2
  6. data/lib/bundler/capistrano.rb +1 -19
  7. data/lib/bundler/cli/cache.rb +1 -11
  8. data/lib/bundler/cli/common.rb +20 -3
  9. data/lib/bundler/cli/config.rb +1 -2
  10. data/lib/bundler/cli/console.rb +5 -0
  11. data/lib/bundler/cli/exec.rb +29 -4
  12. data/lib/bundler/cli/gem.rb +19 -33
  13. data/lib/bundler/cli/install.rb +7 -82
  14. data/lib/bundler/cli/issue.rb +2 -2
  15. data/lib/bundler/cli/list.rb +33 -2
  16. data/lib/bundler/cli/plugin.rb +5 -1
  17. data/lib/bundler/cli/show.rb +1 -1
  18. data/lib/bundler/cli/update.rb +3 -3
  19. data/lib/bundler/cli.rb +75 -83
  20. data/lib/bundler/compact_index_client.rb +0 -1
  21. data/lib/bundler/current_ruby.rb +3 -15
  22. data/lib/bundler/definition.rb +45 -35
  23. data/lib/bundler/deployment.rb +1 -64
  24. data/lib/bundler/digest.rb +1 -1
  25. data/lib/bundler/dsl.rb +13 -35
  26. data/lib/bundler/endpoint_specification.rb +0 -22
  27. data/lib/bundler/errors.rb +1 -5
  28. data/lib/bundler/feature_flag.rb +0 -33
  29. data/lib/bundler/fetcher/compact_index.rb +1 -1
  30. data/lib/bundler/friendly_errors.rb +2 -2
  31. data/lib/bundler/index.rb +0 -7
  32. data/lib/bundler/inline.rb +1 -1
  33. data/lib/bundler/installer/gem_installer.rb +0 -11
  34. data/lib/bundler/installer.rb +0 -6
  35. data/lib/bundler/lockfile_generator.rb +1 -1
  36. data/lib/bundler/lockfile_parser.rb +2 -12
  37. data/lib/bundler/man/bundle-add.1 +1 -1
  38. data/lib/bundler/man/bundle-binstubs.1 +3 -6
  39. data/lib/bundler/man/bundle-binstubs.1.ronn +4 -6
  40. data/lib/bundler/man/bundle-cache.1 +2 -14
  41. data/lib/bundler/man/bundle-cache.1.ronn +1 -14
  42. data/lib/bundler/man/bundle-check.1 +2 -5
  43. data/lib/bundler/man/bundle-check.1.ronn +0 -5
  44. data/lib/bundler/man/bundle-clean.1 +1 -1
  45. data/lib/bundler/man/bundle-config.1 +6 -33
  46. data/lib/bundler/man/bundle-config.1.ronn +20 -55
  47. data/lib/bundler/man/bundle-console.1 +1 -1
  48. data/lib/bundler/man/bundle-doctor.1 +1 -1
  49. data/lib/bundler/man/bundle-env.1 +1 -1
  50. data/lib/bundler/man/bundle-exec.1 +2 -5
  51. data/lib/bundler/man/bundle-exec.1.ronn +1 -5
  52. data/lib/bundler/man/bundle-fund.1 +1 -1
  53. data/lib/bundler/man/bundle-gem.1 +3 -6
  54. data/lib/bundler/man/bundle-gem.1.ronn +2 -5
  55. data/lib/bundler/man/bundle-help.1 +1 -1
  56. data/lib/bundler/man/bundle-info.1 +1 -1
  57. data/lib/bundler/man/bundle-init.1 +1 -1
  58. data/lib/bundler/man/bundle-install.1 +8 -59
  59. data/lib/bundler/man/bundle-install.1.ronn +12 -107
  60. data/lib/bundler/man/bundle-issue.1 +1 -1
  61. data/lib/bundler/man/bundle-licenses.1 +1 -1
  62. data/lib/bundler/man/bundle-list.1 +6 -1
  63. data/lib/bundler/man/bundle-list.1.ronn +5 -0
  64. data/lib/bundler/man/bundle-lock.1 +1 -1
  65. data/lib/bundler/man/bundle-open.1 +1 -1
  66. data/lib/bundler/man/bundle-outdated.1 +1 -1
  67. data/lib/bundler/man/bundle-platform.1 +1 -1
  68. data/lib/bundler/man/bundle-plugin.1 +2 -9
  69. data/lib/bundler/man/bundle-plugin.1.ronn +0 -8
  70. data/lib/bundler/man/bundle-pristine.1 +1 -1
  71. data/lib/bundler/man/bundle-remove.1 +2 -8
  72. data/lib/bundler/man/bundle-remove.1.ronn +1 -8
  73. data/lib/bundler/man/bundle-show.1 +2 -5
  74. data/lib/bundler/man/bundle-show.1.ronn +0 -4
  75. data/lib/bundler/man/bundle-update.1 +1 -1
  76. data/lib/bundler/man/bundle-version.1 +1 -1
  77. data/lib/bundler/man/bundle.1 +1 -10
  78. data/lib/bundler/man/bundle.1.ronn +0 -9
  79. data/lib/bundler/man/gemfile.5 +1 -1
  80. data/lib/bundler/man/index.txt +0 -2
  81. data/lib/bundler/materialization.rb +1 -1
  82. data/lib/bundler/plugin/installer.rb +0 -10
  83. data/lib/bundler/plugin/source_list.rb +1 -1
  84. data/lib/bundler/plugin.rb +1 -1
  85. data/lib/bundler/resolver.rb +1 -1
  86. data/lib/bundler/ruby_dsl.rb +2 -0
  87. data/lib/bundler/ruby_version.rb +1 -3
  88. data/lib/bundler/rubygems_ext.rb +1 -1
  89. data/lib/bundler/rubygems_gem_installer.rb +1 -1
  90. data/lib/bundler/rubygems_integration.rb +1 -5
  91. data/lib/bundler/self_manager.rb +1 -1
  92. data/lib/bundler/settings.rb +7 -26
  93. data/lib/bundler/shared_helpers.rb +8 -20
  94. data/lib/bundler/source/git/git_proxy.rb +3 -11
  95. data/lib/bundler/source/git.rb +2 -3
  96. data/lib/bundler/source/path.rb +3 -7
  97. data/lib/bundler/source/rubygems.rb +11 -17
  98. data/lib/bundler/source.rb +1 -1
  99. data/lib/bundler/source_list.rb +4 -45
  100. data/lib/bundler/source_map.rb +2 -5
  101. data/lib/bundler/spec_set.rb +6 -15
  102. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +7 -129
  103. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  104. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  105. data/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
  106. data/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
  107. data/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
  108. data/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
  109. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +6 -0
  110. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  111. data/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -1
  112. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +26 -23
  113. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  114. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +50 -6
  115. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +57 -52
  116. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +5 -2
  117. data/lib/bundler/vendor/thor/lib/thor/runner.rb +1 -1
  118. data/lib/bundler/vendor/uri/lib/uri/common.rb +57 -15
  119. data/lib/bundler/vendor/uri/lib/uri/file.rb +1 -1
  120. data/lib/bundler/vendor/uri/lib/uri/generic.rb +34 -21
  121. data/lib/bundler/vendor/uri/lib/uri/http.rb +12 -0
  122. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  123. data/lib/bundler/vendor/uri/lib/uri/version.rb +2 -2
  124. data/lib/bundler/version.rb +1 -1
  125. data/lib/bundler/vlad.rb +1 -14
  126. data/lib/bundler.rb +6 -28
  127. metadata +9 -13
  128. data/lib/bundler/cli/inject.rb +0 -60
  129. data/lib/bundler/cli/viz.rb +0 -31
  130. data/lib/bundler/graph.rb +0 -152
  131. data/lib/bundler/man/bundle-inject.1 +0 -31
  132. data/lib/bundler/man/bundle-inject.1.ronn +0 -32
  133. data/lib/bundler/man/bundle-viz.1 +0 -30
  134. data/lib/bundler/man/bundle-viz.1.ronn +0 -36
  135. data/lib/bundler/similarity_detector.rb +0 -63
data/lib/bundler/cli.rb CHANGED
@@ -11,7 +11,7 @@ module Bundler
11
11
 
12
12
  AUTO_INSTALL_CMDS = %w[show binstubs outdated exec open console licenses clean].freeze
13
13
  PARSEABLE_COMMANDS = %w[check config help exec platform show version].freeze
14
- EXTENSIONS = ["c", "rust"].freeze
14
+ EXTENSIONS = ["c", "rust", "go"].freeze
15
15
 
16
16
  COMMAND_ALIASES = {
17
17
  "check" => "c",
@@ -24,7 +24,7 @@ module Bundler
24
24
  }.freeze
25
25
 
26
26
  def self.start(*)
27
- check_deprecated_ext_option(ARGV) if ARGV.include?("--ext")
27
+ check_invalid_ext_option(ARGV) if ARGV.include?("--ext")
28
28
 
29
29
  super
30
30
  ensure
@@ -107,7 +107,22 @@ module Bundler
107
107
  shell.say
108
108
  self.class.send(:class_options_help, shell)
109
109
  end
110
- default_task(Bundler.feature_flag.default_cli_command)
110
+
111
+ def self.default_command(meth = nil)
112
+ return super if meth
113
+
114
+ default_cli_command = Bundler.settings[:default_cli_command]
115
+ return default_cli_command if default_cli_command
116
+
117
+ Bundler.ui.warn(<<~MSG)
118
+ In the next version of Bundler, running `bundle` without argument will no longer run `bundle install`.
119
+ Instead, the `help` command will be displayed.
120
+
121
+ If you'd like to keep the previous behaviour please run `bundle config set default_cli_command install --global`.
122
+ MSG
123
+
124
+ "install"
125
+ end
111
126
 
112
127
  class_option "no-color", type: :boolean, desc: "Disable colorization in output"
113
128
  class_option "retry", type: :numeric, aliases: "-r", banner: "NUM",
@@ -143,7 +158,7 @@ module Bundler
143
158
  end
144
159
 
145
160
  def self.handle_no_command_error(command, has_namespace = $thor_runner)
146
- if Bundler.feature_flag.plugins? && Bundler::Plugin.command?(command)
161
+ if Bundler.settings[:plugins] && Bundler::Plugin.command?(command)
147
162
  return Bundler::Plugin.exec_command(command, ARGV[1..-1])
148
163
  end
149
164
 
@@ -173,7 +188,7 @@ module Bundler
173
188
  D
174
189
  method_option "dry-run", type: :boolean, default: false, banner: "Lock the Gemfile"
175
190
  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?}"
191
+ method_option "path", type: :string, banner: "Specify a different path than the system default, namely, $BUNDLE_PATH or $GEM_HOME (removed)"
177
192
  def check
178
193
  remembered_flag_deprecation("path")
179
194
 
@@ -187,12 +202,11 @@ module Bundler
187
202
  long_desc <<-D
188
203
  Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid. If the gem is not found, Bundler prints a error message and if gem could not be removed due to any reason Bundler will display a warning.
189
204
  D
190
- method_option "install", type: :boolean, banner: "Runs 'bundle install' after removing the gems from the Gemfile"
205
+ method_option "install", type: :boolean, banner: "Runs 'bundle install' after removing the gems from the Gemfile (removed)"
191
206
  def remove(*gems)
192
207
  if ARGV.include?("--install")
193
- message = "The `--install` flag has been deprecated. `bundle install` is triggered by default."
194
208
  removed_message = "The `--install` flag has been removed. `bundle install` is triggered by default."
195
- SharedHelpers.major_deprecation(2, message, removed_message: removed_message)
209
+ raise InvalidOption, removed_message
196
210
  end
197
211
 
198
212
  require_relative "cli/remove"
@@ -210,10 +224,10 @@ module Bundler
210
224
 
211
225
  If the bundle has already been installed, bundler will tell you so and then exit.
212
226
  D
213
- 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"
227
+ method_option "binstubs", type: :string, lazy_default: "bin", banner: "Generate bin stubs for bundled gems to ./bin (removed)"
228
+ method_option "clean", type: :boolean, banner: "Run bundle clean automatically after install (removed)"
229
+ method_option "deployment", type: :boolean, banner: "Install using defaults tuned for deployment environments (removed)"
230
+ method_option "frozen", type: :boolean, banner: "Do not allow the Gemfile.lock to be updated after this install (removed)"
217
231
  method_option "full-index", type: :boolean, banner: "Fall back to using the single-file index of all gems"
218
232
  method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
219
233
  method_option "jobs", aliases: "-j", type: :numeric, banner: "Specify the number of jobs to run in parallel"
@@ -221,16 +235,16 @@ module Bundler
221
235
  method_option "prefer-local", type: :boolean, banner: "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely"
222
236
  method_option "no-cache", type: :boolean, banner: "Don't update the existing gem cache."
223
237
  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?}"
238
+ method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache (removed)."
239
+ method_option "path", type: :string, banner: "Specify a different path than the system default, namely, $BUNDLE_PATH or $GEM_HOME (removed)."
226
240
  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')"
241
+ method_option "shebang", type: :string, banner: "Specify a different shebang executable name than the default, usually 'ruby' (removed)"
228
242
  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"
243
+ 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)"
230
244
  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("|")}"
231
245
  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."
246
+ method_option "without", type: :array, banner: "Exclude gems that are part of the specified named group (removed)."
247
+ method_option "with", type: :array, banner: "Include gems that are part of the specified named group (removed)."
234
248
  def install
235
249
  %w[clean deployment frozen no-prune path shebang without with].each do |option|
236
250
  remembered_flag_deprecation(option)
@@ -240,6 +254,11 @@ module Bundler
240
254
 
241
255
  remembered_flag_deprecation("deployment", negative: true)
242
256
 
257
+ if ARGV.include?("--binstubs")
258
+ removed_message = "The --binstubs option has been removed in favor of `bundle binstubs --all`"
259
+ raise InvalidOption, removed_message
260
+ end
261
+
243
262
  require_relative "cli/install"
244
263
  Bundler.settings.temporary(no_install: false) do
245
264
  Install.new(options.dup).run
@@ -284,12 +303,11 @@ module Bundler
284
303
  Calling show with [GEM] will list the exact location of that gem on your machine.
285
304
  D
286
305
  method_option "paths", type: :boolean, banner: "List the paths of all gems that are required by your Gemfile."
287
- method_option "outdated", type: :boolean, banner: "Show verbose output including whether gems are outdated."
306
+ method_option "outdated", type: :boolean, banner: "Show verbose output including whether gems are outdated (removed)."
288
307
  def show(gem_name = nil)
289
308
  if ARGV.include?("--outdated")
290
- message = "the `--outdated` flag to `bundle show` will be removed in favor of `bundle show --verbose`"
291
309
  removed_message = "the `--outdated` flag to `bundle show` has been removed in favor of `bundle show --verbose`"
292
- SharedHelpers.major_deprecation(2, message, removed_message: removed_message)
310
+ raise InvalidOption, removed_message
293
311
  end
294
312
  require_relative "cli/show"
295
313
  Show.new(options, gem_name).run
@@ -299,6 +317,7 @@ module Bundler
299
317
  method_option "name-only", type: :boolean, banner: "print only the gem names"
300
318
  method_option "only-group", type: :array, default: [], banner: "print gems from a given set of groups"
301
319
  method_option "without-group", type: :array, default: [], banner: "print all gems except from a given set of groups"
320
+ method_option "format", type: :string, banner: "format output ('json' is the only supported format)"
302
321
  method_option "paths", type: :boolean, banner: "print the path to each gem in the bundle"
303
322
  def list
304
323
  require_relative "cli/list"
@@ -322,7 +341,7 @@ module Bundler
322
341
  will create binstubs for all given gems.
323
342
  D
324
343
  method_option "force", type: :boolean, default: false, banner: "Overwrite existing binstubs if they exist"
325
- method_option "path", type: :string, lazy_default: "bin", banner: "Binstub destination directory (default bin)"
344
+ method_option "path", type: :string, lazy_default: "bin", banner: "Binstub destination directory, `bin` by default (removed)"
326
345
  method_option "shebang", type: :string, banner: "Specify a different shebang executable name than the default (usually 'ruby')"
327
346
  method_option "standalone", type: :boolean, banner: "Make binstubs that can work without the Bundler runtime"
328
347
  method_option "all", type: :boolean, banner: "Install binstubs for all gems"
@@ -395,15 +414,15 @@ module Bundler
395
414
  end
396
415
 
397
416
  desc "cache [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
398
- method_option "all", type: :boolean, default: Bundler.feature_flag.cache_all?, banner: "Include all sources (including path and git)."
417
+ method_option "all", type: :boolean, default: Bundler.settings[:cache_all], banner: "Include all sources (including path and git) (removed)."
399
418
  method_option "all-platforms", type: :boolean, banner: "Include gems for all platforms present in the lockfile, not only the current one"
400
419
  method_option "cache-path", type: :string, banner: "Specify a different cache path than the default (vendor/cache)."
401
420
  method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
402
421
  method_option "no-install", type: :boolean, banner: "Don't install the gems, only update the cache."
403
- method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache."
404
- 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?}"
422
+ method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache (removed)."
423
+ method_option "path", type: :string, banner: "Specify a different path than the system default, namely, $BUNDLE_PATH or $GEM_HOME (removed)."
405
424
  method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
406
- method_option "frozen", type: :boolean, banner: "Do not allow the Gemfile.lock to be updated after this bundle cache operation's install"
425
+ method_option "frozen", type: :boolean, banner: "Do not allow the Gemfile.lock to be updated after this bundle cache operation's install (removed)"
407
426
  long_desc <<-D
408
427
  The cache command will copy the .gem files for every gem in the bundle into the
409
428
  directory ./vendor/cache. If you then check that directory into your source
@@ -419,16 +438,12 @@ module Bundler
419
438
  end
420
439
 
421
440
  if flag_passed?("--path")
422
- message =
423
- "The `--path` flag is deprecated because its semantics are unclear. " \
424
- "Use `bundle config cache_path` to configure the path of your cache of gems, " \
425
- "and `bundle config path` to configure the path where your gems are installed, " \
426
- "and stop using this flag"
427
441
  removed_message =
428
442
  "The `--path` flag has been removed because its semantics were unclear. " \
429
443
  "Use `bundle config cache_path` to configure the path of your cache of gems, " \
430
- "and `bundle config path` to configure the path where your gems are installed."
431
- SharedHelpers.major_deprecation 2, message, removed_message: removed_message
444
+ "and `bundle config path` to configure the path where your gems are installed, " \
445
+ "and stop using this flag"
446
+ raise InvalidOption, removed_message
432
447
  end
433
448
 
434
449
  require_relative "cli/cache"
@@ -438,7 +453,7 @@ module Bundler
438
453
  map aliases_for("cache")
439
454
 
440
455
  desc "exec [OPTIONS]", "Run the command in context of the bundle"
441
- method_option :keep_file_descriptors, type: :boolean, default: true, banner: "Passes all file descriptors to the new processes. Default is true, and setting it to false is deprecated"
456
+ method_option :keep_file_descriptors, type: :boolean, default: true, banner: "Passes all file descriptors to the new processes. Default is true, and setting it to false is not permitted (removed)."
442
457
  method_option :gemfile, type: :string, required: false, banner: "Use the specified gemfile instead of Gemfile"
443
458
  long_desc <<-D
444
459
  Exec runs a command, providing it access to the gems in the bundle. While using
@@ -447,9 +462,8 @@ module Bundler
447
462
  D
448
463
  def exec(*args)
449
464
  if ARGV.include?("--no-keep-file-descriptors")
450
- 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"
451
465
  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"
452
- SharedHelpers.major_deprecation(2, message, removed_message: removed_message)
466
+ raise InvalidOption, removed_message
453
467
  end
454
468
 
455
469
  require_relative "cli/exec"
@@ -493,7 +507,7 @@ module Bundler
493
507
  build_info = " (#{BuildMetadata.timestamp} commit #{BuildMetadata.git_commit_sha})"
494
508
  end
495
509
 
496
- if !cli_help && Bundler.feature_flag.bundler_4_mode?
510
+ if !cli_help
497
511
  Bundler.ui.info "#{Bundler.verbose_version}#{build_info}"
498
512
  else
499
513
  Bundler.ui.info "Bundler version #{Bundler.verbose_version}#{build_info}"
@@ -516,23 +530,9 @@ module Bundler
516
530
  end
517
531
  end
518
532
 
519
- unless Bundler.feature_flag.bundler_4_mode?
520
- desc "viz [OPTIONS]", "Generates a visual dependency graph", hide: true
521
- long_desc <<-D
522
- Viz generates a PNG file of the current Gemfile as a dependency graph.
523
- Viz requires the ruby-graphviz gem (and its dependencies).
524
- The associated gems must also be installed via 'bundle install'.
525
- D
526
- method_option :file, type: :string, default: "gem_graph", aliases: "-f", banner: "The name to use for the generated file. see format option"
527
- method_option :format, type: :string, default: "png", aliases: "-F", banner: "This is output format option. Supported format is png, jpg, svg, dot ..."
528
- method_option :requirements, type: :boolean, default: false, aliases: "-R", banner: "Set to show the version of each required dependency."
529
- method_option :version, type: :boolean, default: false, aliases: "-v", banner: "Set to show each gem version."
530
- method_option :without, type: :array, default: [], aliases: "-W", banner: "Exclude gems that are part of the specified named group."
531
- def viz
532
- SharedHelpers.major_deprecation 2, "The `viz` command has been renamed to `graph` and moved to a plugin. See https://github.com/rubygems/bundler-graph"
533
- require_relative "cli/viz"
534
- Viz.new(options.dup).run
535
- end
533
+ desc "viz [OPTIONS]", "Generates a visual dependency graph", hide: true
534
+ def viz
535
+ SharedHelpers.feature_removed! "The `viz` command has been renamed to `graph` and moved to a plugin. See https://github.com/rubygems/bundler-graph"
536
536
  end
537
537
 
538
538
  desc "gem NAME [OPTIONS]", "Creates a skeleton for creating a rubygem"
@@ -542,7 +542,7 @@ module Bundler
542
542
  method_option :ext, type: :string, banner: "Generate the boilerplate for C extension code.", enum: EXTENSIONS
543
543
  method_option :git, type: :boolean, default: true, banner: "Initialize a git repo inside your library."
544
544
  method_option :mit, type: :boolean, banner: "Generate an MIT license file. Set a default with `bundle config set --global gem.mit true`."
545
- method_option :rubocop, type: :boolean, banner: "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true`."
545
+ method_option :rubocop, type: :boolean, banner: "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true` (removed)."
546
546
  method_option :changelog, type: :boolean, banner: "Generate changelog file. Set a default with `bundle config set --global gem.changelog true`."
547
547
  method_option :test, type: :string, lazy_default: Bundler.settings["gem.test"] || "", aliases: "-t", banner: "Use the specified test framework for your library", enum: %w[rspec minitest test-unit], desc: "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
548
548
  method_option :ci, type: :string, lazy_default: Bundler.settings["gem.ci"] || "", enum: %w[github gitlab circle], banner: "Generate CI configuration, either GitHub Actions, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|gitlab|circle)`"
@@ -552,6 +552,10 @@ module Bundler
552
552
 
553
553
  def gem(name)
554
554
  require_relative "cli/gem"
555
+
556
+ raise InvalidOption, "--rubocop has been removed, use --linter=rubocop" if ARGV.include?("--rubocop")
557
+ raise InvalidOption, "--no-rubocop has been removed, use --no-linter" if ARGV.include?("--no-rubocop")
558
+
555
559
  cmd_args = args + [self]
556
560
  cmd_args.unshift(options)
557
561
 
@@ -562,7 +566,7 @@ module Bundler
562
566
  File.expand_path("templates", __dir__)
563
567
  end
564
568
 
565
- desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory", hide: true
569
+ desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory"
566
570
  method_option "dry-run", type: :boolean, default: false, banner: "Only print out changes, do not clean gems"
567
571
  method_option "force", type: :boolean, default: false, banner: "Forces cleaning up unused gems even if Bundler is configured to use globally installed gems. As a consequence, removes all system gems except for the ones in the current application."
568
572
  def clean
@@ -578,12 +582,8 @@ module Bundler
578
582
  end
579
583
 
580
584
  desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile", hide: true
581
- method_option "source", type: :string, banner: "Install gem from the given source"
582
- method_option "group", type: :string, banner: "Install gem into a bundler group"
583
- def inject(name, version)
584
- SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command"
585
- require_relative "cli/inject"
586
- Inject.new(options.dup, name, version).run
585
+ def inject(*)
586
+ SharedHelpers.feature_removed! "The `inject` command has been replaced by the `add` command"
587
587
  end
588
588
 
589
589
  desc "lock", "Creates a lockfile without installing"
@@ -637,7 +637,7 @@ module Bundler
637
637
  end
638
638
  end
639
639
 
640
- if Bundler.feature_flag.plugins?
640
+ if Bundler.settings[:plugins]
641
641
  require_relative "cli/plugin"
642
642
  desc "plugin", "Manage the bundler plugins"
643
643
  subcommand "plugin", Plugin
@@ -671,18 +671,15 @@ module Bundler
671
671
  end
672
672
  end
673
673
 
674
- def self.check_deprecated_ext_option(arguments)
675
- # when deprecated version of `--ext` is called
676
- # print out deprecation warning and pretend `--ext=c` was provided
677
- if deprecated_ext_value?(arguments)
678
- 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."
674
+ def self.check_invalid_ext_option(arguments)
675
+ # when invalid version of `--ext` is called
676
+ if invalid_ext_value?(arguments)
679
677
  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."
680
- SharedHelpers.major_deprecation 2, message, removed_message: removed_message
681
- arguments[arguments.index("--ext")] = "--ext=c"
678
+ raise InvalidOption, removed_message
682
679
  end
683
680
  end
684
681
 
685
- def self.deprecated_ext_value?(arguments)
682
+ def self.invalid_ext_value?(arguments)
686
683
  index = arguments.index("--ext")
687
684
  next_argument = arguments[index + 1]
688
685
 
@@ -690,15 +687,15 @@ module Bundler
690
687
  # for example `bundle gem hello --ext c`
691
688
  return false if EXTENSIONS.include?(next_argument)
692
689
 
693
- # deprecated call when --ext is called with no value in last position
690
+ # invalid call when --ext is called with no value in last position
694
691
  # for example `bundle gem hello_gem --ext`
695
692
  return true if next_argument.nil?
696
693
 
697
- # deprecated call when --ext is followed by other parameter
694
+ # invalid call when --ext is followed by other parameter
698
695
  # for example `bundle gem --ext --no-ci hello_gem`
699
696
  return true if next_argument.start_with?("-")
700
697
 
701
- # deprecated call when --ext is followed by gem name
698
+ # invalid call when --ext is followed by gem name
702
699
  # for example `bundle gem --ext hello_gem`
703
700
  return true if next_argument
704
701
 
@@ -766,17 +763,12 @@ module Bundler
766
763
  end
767
764
 
768
765
  def print_remembered_flag_deprecation(flag_name, option_name, option_value)
769
- message =
770
- "The `#{flag_name}` flag is deprecated because it relies on being " \
771
- "remembered across bundler invocations, which bundler will no longer " \
772
- "do in future versions. Instead please use `bundle config set #{option_name} " \
773
- "#{option_value}`, and stop using this flag"
774
766
  removed_message =
775
767
  "The `#{flag_name}` flag has been removed because it relied on being " \
776
- "remembered across bundler invocations, which bundler will no longer " \
777
- "do. Instead please use `bundle config set #{option_name} " \
778
- "#{option_value}`, and stop using this flag"
779
- Bundler::SharedHelpers.major_deprecation 2, message, removed_message: removed_message
768
+ "remembered across bundler invocations, which bundler no longer does. " \
769
+ "Instead please use `bundle config set #{option_name} #{option_value}`, " \
770
+ "and stop using this flag"
771
+ raise InvalidOption, removed_message
780
772
  end
781
773
 
782
774
  def flag_passed?(name)
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "pathname"
4
3
  require "set"
5
4
 
6
5
  module Bundler
@@ -11,7 +11,7 @@ module Bundler
11
11
  end
12
12
 
13
13
  class CurrentRuby
14
- ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..35).to_a).freeze
14
+ ALL_RUBY_VERSIONS = [*18..27, *30..34, 40].freeze
15
15
  KNOWN_MINOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.reverse.join(".") }.freeze
16
16
  KNOWN_MAJOR_VERSIONS = ALL_RUBY_VERSIONS.map {|v| v.digits.last.to_s }.uniq.freeze
17
17
  PLATFORM_MAP = {
@@ -50,19 +50,10 @@ module Bundler
50
50
  end
51
51
 
52
52
  def maglev?
53
- message =
54
- "`CurrentRuby#maglev?` is deprecated with no replacement. Please use the " \
55
- "built-in Ruby `RUBY_ENGINE` constant to check the Ruby implementation you are running on."
56
53
  removed_message =
57
54
  "`CurrentRuby#maglev?` was removed with no replacement. Please use the " \
58
55
  "built-in Ruby `RUBY_ENGINE` constant to check the Ruby implementation you are running on."
59
- internally_exempted = caller_locations(1, 1).first.path == __FILE__
60
-
61
- unless internally_exempted
62
- SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
63
- end
64
-
65
- RUBY_ENGINE == "maglev"
56
+ SharedHelpers.feature_removed!(removed_message)
66
57
  end
67
58
 
68
59
  def truffleruby?
@@ -90,14 +81,11 @@ module Bundler
90
81
  end
91
82
 
92
83
  define_method(:"maglev_#{trimmed_version}?") do
93
- message =
94
- "`CurrentRuby##{__method__}` is deprecated with no replacement. Please use the " \
95
- "built-in Ruby `RUBY_ENGINE` and `RUBY_VERSION` constants to perform a similar check."
96
84
  removed_message =
97
85
  "`CurrentRuby##{__method__}` was removed with no replacement. Please use the " \
98
86
  "built-in Ruby `RUBY_ENGINE` and `RUBY_VERSION` constants to perform a similar check."
99
87
 
100
- SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
88
+ SharedHelpers.feature_removed!(removed_message)
101
89
 
102
90
  send(:"maglev?") && send(:"on_#{trimmed_version}?")
103
91
  end
@@ -107,6 +107,7 @@ module Bundler
107
107
  @locked_ruby_version = @locked_gems.ruby_version
108
108
  @locked_deps = @locked_gems.dependencies
109
109
  @originally_locked_specs = SpecSet.new(@locked_gems.specs)
110
+ @originally_locked_sources = @locked_gems.sources
110
111
  @locked_checksums = @locked_gems.checksums
111
112
 
112
113
  if @unlocking_all
@@ -114,7 +115,16 @@ module Bundler
114
115
  @locked_sources = []
115
116
  else
116
117
  @locked_specs = @originally_locked_specs
117
- @locked_sources = @locked_gems.sources
118
+ @locked_sources = @originally_locked_sources
119
+ end
120
+
121
+ locked_gem_sources = @originally_locked_sources.select {|s| s.is_a?(Source::Rubygems) }
122
+ multisource_lockfile = locked_gem_sources.size == 1 && locked_gem_sources.first.multiple_remotes?
123
+
124
+ if multisource_lockfile
125
+ msg = "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. Make sure you run `bundle install` in non frozen mode and commit the result to make your lockfile secure."
126
+
127
+ Bundler::SharedHelpers.feature_removed! msg
118
128
  end
119
129
  else
120
130
  @locked_gems = nil
@@ -123,22 +133,10 @@ module Bundler
123
133
  @platforms = []
124
134
  @locked_deps = {}
125
135
  @locked_specs = SpecSet.new([])
126
- @originally_locked_specs = @locked_specs
127
136
  @locked_sources = []
128
- @locked_checksums = Bundler.feature_flag.lockfile_checksums?
129
- end
130
-
131
- locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
132
- @multisource_allowed = locked_gem_sources.size == 1 && locked_gem_sources.first.multiple_remotes? && Bundler.frozen_bundle?
133
-
134
- if @multisource_allowed
135
- unless sources.aggregate_global_source?
136
- msg = "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. Make sure you run `bundle install` in non frozen mode and commit the result to make your lockfile secure."
137
-
138
- Bundler::SharedHelpers.major_deprecation 2, msg
139
- end
140
-
141
- @sources.merged_gem_lockfile_sections!(locked_gem_sources.first)
137
+ @originally_locked_specs = @locked_specs
138
+ @originally_locked_sources = @locked_sources
139
+ @locked_checksums = Bundler.settings[:lockfile_checksums]
142
140
  end
143
141
 
144
142
  @unlocking_ruby ||= if @ruby_version && locked_ruby_version_object
@@ -284,12 +282,17 @@ module Bundler
284
282
  end
285
283
 
286
284
  def filter_relevant(dependencies)
287
- platforms_array = [Bundler.generic_local_platform].freeze
288
285
  dependencies.select do |d|
289
- d.should_include? && !d.gem_platforms(platforms_array).empty?
286
+ relevant_deps?(d)
290
287
  end
291
288
  end
292
289
 
290
+ def relevant_deps?(dep)
291
+ platforms_array = [Bundler.generic_local_platform].freeze
292
+
293
+ dep.should_include? && !dep.gem_platforms(platforms_array).empty?
294
+ end
295
+
293
296
  def locked_dependencies
294
297
  @locked_deps.values
295
298
  end
@@ -369,7 +372,7 @@ module Bundler
369
372
 
370
373
  msg = "`Definition#lock` was passed a target file argument. #{suggestion}"
371
374
 
372
- Bundler::SharedHelpers.major_deprecation 2, msg
375
+ Bundler::SharedHelpers.feature_removed! msg
373
376
  end
374
377
 
375
378
  write_lock(target_lockfile, preserve_unknown_sections)
@@ -537,7 +540,18 @@ module Bundler
537
540
 
538
541
  setup_domain!(add_checksums: true)
539
542
 
540
- specs # force materialization to real specifications, so that checksums are fetched
543
+ # force materialization to real specifications, so that checksums are fetched
544
+ specs.each do |spec|
545
+ next unless spec.source.is_a?(Bundler::Source::Rubygems)
546
+ # Checksum was fetched from the compact index API.
547
+ next if !spec.source.checksum_store.missing?(spec) && !spec.source.checksum_store.empty?(spec)
548
+ # The gem isn't installed, can't compute the checksum.
549
+ next unless spec.loaded_from
550
+
551
+ package = Gem::Package.new(spec.source.cached_built_in_gem(spec))
552
+ checksum = Checksum.from_gem_package(package)
553
+ spec.source.checksum_store.register(spec, checksum)
554
+ end
541
555
  end
542
556
 
543
557
  private
@@ -645,20 +659,12 @@ module Bundler
645
659
  end
646
660
 
647
661
  def materialize(dependencies)
648
- # Tracks potential endless loops trying to re-resolve.
649
- # TODO: Remove as dead code if not reports are received in a while
650
- incorrect_spec = nil
651
-
652
662
  specs = begin
653
663
  resolve.materialize(dependencies)
654
664
  rescue IncorrectLockfileDependencies => e
655
665
  raise if Bundler.frozen_bundle?
656
666
 
657
- spec = e.spec
658
- raise "Infinite loop while fixing lockfile dependencies" if incorrect_spec == spec
659
-
660
- incorrect_spec = spec
661
- reresolve_without([spec])
667
+ reresolve_without([e.spec])
662
668
  retry
663
669
  end
664
670
 
@@ -771,7 +777,7 @@ module Bundler
771
777
  end
772
778
 
773
779
  def precompute_source_requirements_for_indirect_dependencies?
774
- sources.non_global_rubygems_sources.all?(&:dependency_api_available?) && !sources.aggregate_global_source?
780
+ sources.non_global_rubygems_sources.all?(&:dependency_api_available?)
775
781
  end
776
782
 
777
783
  def current_platform_locked?
@@ -962,7 +968,7 @@ module Bundler
962
968
  sources.all_sources.each do |source|
963
969
  # has to be done separately, because we want to keep the locked checksum
964
970
  # store for a source, even when doing a full update
965
- if @locked_checksums && @locked_gems && locked_source = @locked_gems.sources.find {|s| s == source && !s.equal?(source) }
971
+ if @locked_checksums && @locked_gems && locked_source = @originally_locked_sources.find {|s| s == source && !s.equal?(source) }
966
972
  source.checksum_store.merge!(locked_source.checksum_store)
967
973
  end
968
974
  # If the source is unlockable and the current command allows an unlock of
@@ -983,10 +989,11 @@ module Bundler
983
989
  @missing_lockfile_dep = nil
984
990
  @changed_dependencies = []
985
991
 
986
- current_dependencies.each do |dep|
992
+ @dependencies.each do |dep|
987
993
  if dep.source
988
994
  dep.source = sources.get(dep.source)
989
995
  end
996
+ next unless relevant_deps?(dep)
990
997
 
991
998
  name = dep.name
992
999
 
@@ -1044,6 +1051,8 @@ module Bundler
1044
1051
 
1045
1052
  specs.each do |s|
1046
1053
  name = s.name
1054
+ next if @gems_to_unlock.include?(name)
1055
+
1047
1056
  dep = @dependencies.find {|d| s.satisfies?(d) }
1048
1057
  lockfile_source = s.source
1049
1058
 
@@ -1057,12 +1066,13 @@ module Bundler
1057
1066
 
1058
1067
  # Replace the locked dependency's source with the equivalent source from the Gemfile
1059
1068
  s.source = replacement_source || default_source
1069
+ next if s.source_changed?
1060
1070
 
1061
1071
  source = s.source
1062
1072
  next if @sources_to_unlock.include?(source.name)
1063
1073
 
1064
1074
  # Path sources have special logic
1065
- if source.instance_of?(Source::Path) || source.instance_of?(Source::Gemspec) || (source.instance_of?(Source::Git) && !@gems_to_unlock.include?(name) && deps.include?(dep))
1075
+ if source.is_a?(Source::Path)
1066
1076
  new_spec = source.specs[s].first
1067
1077
  if new_spec
1068
1078
  s.runtime_dependencies.replace(new_spec.runtime_dependencies)
@@ -1142,9 +1152,9 @@ module Bundler
1142
1152
  end
1143
1153
 
1144
1154
  def additional_base_requirements_to_prevent_downgrades(resolution_base)
1145
- return resolution_base unless @locked_gems && !sources.expired_sources?(@locked_gems.sources)
1155
+ return resolution_base unless @locked_gems
1146
1156
  @originally_locked_specs.each do |locked_spec|
1147
- next if locked_spec.source.is_a?(Source::Path)
1157
+ next if locked_spec.source.is_a?(Source::Path) || locked_spec.source_changed?
1148
1158
 
1149
1159
  name = locked_spec.name
1150
1160
  next if @changed_dependencies.include?(name)