rubygems-update 3.4.10 → 3.4.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +51 -1
  3. data/CONTRIBUTING.md +1 -1
  4. data/Manifest.txt +6 -0
  5. data/bundler/CHANGELOG.md +58 -0
  6. data/bundler/exe/bundle +5 -13
  7. data/bundler/lib/bundler/build_metadata.rb +2 -2
  8. data/bundler/lib/bundler/definition.rb +76 -36
  9. data/bundler/lib/bundler/gem_version_promoter.rb +1 -1
  10. data/bundler/lib/bundler/installer.rb +1 -1
  11. data/bundler/lib/bundler/lazy_specification.rb +1 -1
  12. data/bundler/lib/bundler/lockfile_generator.rb +1 -1
  13. data/bundler/lib/bundler/lockfile_parser.rb +1 -0
  14. data/bundler/lib/bundler/man/bundle-cache.1 +2 -2
  15. data/bundler/lib/bundler/man/bundle-cache.1.ronn +2 -2
  16. data/bundler/lib/bundler/resolver/base.rb +1 -3
  17. data/bundler/lib/bundler/resolver.rb +16 -2
  18. data/bundler/lib/bundler/ruby_version.rb +1 -1
  19. data/bundler/lib/bundler/rubygems_ext.rb +5 -3
  20. data/bundler/lib/bundler/runtime.rb +1 -1
  21. data/bundler/lib/bundler/safe_marshal.rb +31 -0
  22. data/bundler/lib/bundler/settings.rb +3 -2
  23. data/bundler/lib/bundler/source/rubygems.rb +12 -13
  24. data/bundler/lib/bundler/spec_set.rb +2 -2
  25. data/bundler/lib/bundler/templates/newgem/bin/console.tt +0 -4
  26. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +5 -0
  27. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  28. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -1
  29. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +9 -4
  30. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +2 -2
  31. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  32. data/bundler/lib/bundler/version.rb +1 -1
  33. data/bundler/lib/bundler.rb +8 -16
  34. data/lib/rubygems/command_manager.rb +2 -2
  35. data/lib/rubygems/commands/owner_command.rb +4 -2
  36. data/lib/rubygems/exceptions.rb +10 -0
  37. data/lib/rubygems/ext/builder.rb +3 -4
  38. data/lib/rubygems/ext/cargo_builder.rb +2 -2
  39. data/lib/rubygems/ext/rake_builder.rb +4 -2
  40. data/lib/rubygems/gemcutter_utilities.rb +48 -6
  41. data/lib/rubygems/installer.rb +16 -1
  42. data/lib/rubygems/request_set.rb +2 -2
  43. data/lib/rubygems/shellwords.rb +3 -0
  44. data/lib/rubygems/specification.rb +3 -1
  45. data/lib/rubygems/stub_specification.rb +2 -1
  46. data/lib/rubygems/webauthn_listener/response.rb +161 -0
  47. data/lib/rubygems/webauthn_listener.rb +92 -0
  48. data/lib/rubygems.rb +1 -1
  49. data/rubygems-update.gemspec +4 -3
  50. data/test/rubygems/helper.rb +14 -0
  51. data/test/rubygems/test_bundled_ca.rb +1 -1
  52. data/test/rubygems/test_config.rb +1 -1
  53. data/test/rubygems/test_deprecate.rb +1 -1
  54. data/test/rubygems/test_exit.rb +1 -1
  55. data/test/rubygems/test_gem.rb +7 -0
  56. data/test/rubygems/test_gem_commands_owner_command.rb +67 -0
  57. data/test/rubygems/test_gem_commands_pristine_command.rb +1 -1
  58. data/test/rubygems/test_gem_commands_push_command.rb +73 -0
  59. data/test/rubygems/test_gem_commands_setup_command.rb +1 -1
  60. data/test/rubygems/test_gem_commands_yank_command.rb +84 -0
  61. data/test/rubygems/test_gem_ext_cargo_builder.rb +1 -0
  62. data/test/rubygems/test_gem_gem_runner.rb +5 -5
  63. data/test/rubygems/test_gem_gemcutter_utilities.rb +72 -4
  64. data/test/rubygems/test_gem_installer.rb +50 -2
  65. data/test/rubygems/test_gem_uninstaller.rb +4 -4
  66. data/test/rubygems/test_kernel.rb +1 -1
  67. data/test/rubygems/test_project_sanity.rb +32 -3
  68. data/test/rubygems/test_remote_fetch_error.rb +1 -1
  69. data/test/rubygems/test_webauthn_listener.rb +120 -0
  70. data/test/rubygems/test_webauthn_listener_response.rb +93 -0
  71. data/test/rubygems/utilities.rb +44 -3
  72. metadata +14 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46744d5e03cb80dd7f581f3b934f104c88910b8442d3659b6d41d55777ab7f3a
4
- data.tar.gz: d7a2016d3d9af5bc86f92ec7bdb8ec8199d7de024a5fbe4b4a2cd0584bcbcf37
3
+ metadata.gz: 79b6b95727a03e85042c318c19b9161d61f0f70813bd839229aafe15dd171044
4
+ data.tar.gz: 31630ced1a24e78dc72f9838f6869e4242418f63af238e4cbc15d697384f64ac
5
5
  SHA512:
6
- metadata.gz: 8416a6fc4327c003c86b8f05dcebcb0c073cb098ccf3d08661a121aedfca3d493b7b6440a605b5c1711f57b77ff230124d58492f99a58a4f926dd94992b4355c
7
- data.tar.gz: 67d782b6794632c09340a51b0f46cde1b82f70cc91aed59cb01961ed6ab57ee2c9a9043c08250c0c6889e2bab71faa6b6e6fa71de0e6cf5e85472ffade6ce73c
6
+ metadata.gz: 1d6488ea569f1b00fa710c3cf5aedff8f5f06ce2f019d6b8aa172aba4878457a877a4418301c98ed74b7f62ef97b64cca5929586eb60b7e33366f42511bc995d
7
+ data.tar.gz: 813e2629c91f36981977bd077e89deadee4eca9d503a2c5f72796665b7e771ae5f66b6a7f364a73bca39a170bc3d281fff042f990e04b82b360d81d1e66905a1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,53 @@
1
+ # 3.4.15 / 2023-06-29
2
+
3
+ ## Enhancements:
4
+
5
+ * Installs bundler 2.4.15 as a default gem.
6
+
7
+ ## Bug fixes:
8
+
9
+ * Autoload shellwords when it's needed. Pull request
10
+ [#6734](https://github.com/rubygems/rubygems/pull/6734) by ioquatix
11
+
12
+ ## Documentation:
13
+
14
+ * Update command to test local gem command changes. Pull request
15
+ [#6761](https://github.com/rubygems/rubygems/pull/6761) by jenshenny
16
+
17
+ # 3.4.14 / 2023-06-12
18
+
19
+ ## Enhancements:
20
+
21
+ * Load plugin immediately. Pull request
22
+ [#6673](https://github.com/rubygems/rubygems/pull/6673) by kou
23
+ * Installs bundler 2.4.14 as a default gem.
24
+
25
+ ## Documentation:
26
+
27
+ * Clarify what the `rubygems-update` gem is for, and link to source code
28
+ and guides. Pull request
29
+ [#6710](https://github.com/rubygems/rubygems/pull/6710) by davetron5000
30
+
31
+ # 3.4.13 / 2023-05-09
32
+
33
+ ## Enhancements:
34
+
35
+ * Installs bundler 2.4.13 as a default gem.
36
+
37
+ # 3.4.12 / 2023-04-11
38
+
39
+ ## Enhancements:
40
+
41
+ * [Experimental] Add WebAuthn Support to the CLI. Pull request
42
+ [#6560](https://github.com/rubygems/rubygems/pull/6560) by jenshenny
43
+ * Installs bundler 2.4.12 as a default gem.
44
+
45
+ # 3.4.11 / 2023-04-10
46
+
47
+ ## Enhancements:
48
+
49
+ * Installs bundler 2.4.11 as a default gem.
50
+
1
51
  # 3.4.10 / 2023-03-27
2
52
 
3
53
  ## Enhancements:
@@ -666,7 +716,7 @@
666
716
 
667
717
  ## Enhancements:
668
718
 
669
- * Redact credentails when printing URI. Pull request [#4868](https://github.com/rubygems/rubygems/pull/4868) by intuxicated
719
+ * Redact credentials when printing URI. Pull request [#4868](https://github.com/rubygems/rubygems/pull/4868) by intuxicated
670
720
  * Prefer `require_relative` to `require` for internal requires. Pull
671
721
  request [#4858](https://github.com/rubygems/rubygems/pull/4858) by deivid-rodriguez
672
722
  * Prioritise gems with higher version for fetching metadata, and stop
data/CONTRIBUTING.md CHANGED
@@ -48,7 +48,7 @@ here: https://guides.rubygems.org/contributing/
48
48
 
49
49
  To run commands like `gem install` from the repo:
50
50
 
51
- ruby -Ilib bin/gem install
51
+ ruby -Ilib exe/gem install
52
52
 
53
53
  To run commands like `bundle install` from the repo:
54
54
 
data/Manifest.txt CHANGED
@@ -180,6 +180,7 @@ bundler/lib/bundler/rubygems_ext.rb
180
180
  bundler/lib/bundler/rubygems_gem_installer.rb
181
181
  bundler/lib/bundler/rubygems_integration.rb
182
182
  bundler/lib/bundler/runtime.rb
183
+ bundler/lib/bundler/safe_marshal.rb
183
184
  bundler/lib/bundler/self_manager.rb
184
185
  bundler/lib/bundler/settings.rb
185
186
  bundler/lib/bundler/settings/validator.rb
@@ -508,6 +509,7 @@ lib/rubygems/security/policy.rb
508
509
  lib/rubygems/security/signer.rb
509
510
  lib/rubygems/security/trust_dir.rb
510
511
  lib/rubygems/security_option.rb
512
+ lib/rubygems/shellwords.rb
511
513
  lib/rubygems/source.rb
512
514
  lib/rubygems/source/git.rb
513
515
  lib/rubygems/source/installed.rb
@@ -540,6 +542,8 @@ lib/rubygems/util/list.rb
540
542
  lib/rubygems/validator.rb
541
543
  lib/rubygems/version.rb
542
544
  lib/rubygems/version_option.rb
545
+ lib/rubygems/webauthn_listener.rb
546
+ lib/rubygems/webauthn_listener/response.rb
543
547
  rubygems-update.gemspec
544
548
  setup.rb
545
549
  test/rubygems/alternate_cert.pem
@@ -753,6 +757,8 @@ test/rubygems/test_project_sanity.rb
753
757
  test/rubygems/test_remote_fetch_error.rb
754
758
  test/rubygems/test_require.rb
755
759
  test/rubygems/test_rubygems.rb
760
+ test/rubygems/test_webauthn_listener.rb
761
+ test/rubygems/test_webauthn_listener_response.rb
756
762
  test/rubygems/utilities.rb
757
763
  test/rubygems/wrong_key_cert.pem
758
764
  test/rubygems/wrong_key_cert_32.pem
data/bundler/CHANGELOG.md CHANGED
@@ -1,3 +1,61 @@
1
+ # 2.4.15 (June 29, 2023)
2
+
3
+ ## Enhancements:
4
+
5
+ - Improve edge case error message [#6733](https://github.com/rubygems/rubygems/pull/6733)
6
+
7
+ ## Bug fixes:
8
+
9
+ - Fix `bundle lock --update --bundler` [#6213](https://github.com/rubygems/rubygems/pull/6213)
10
+
11
+ # 2.4.14 (June 12, 2023)
12
+
13
+ ## Enhancements:
14
+
15
+ - Stop publishing Gemfile in default gem template [#6723](https://github.com/rubygems/rubygems/pull/6723)
16
+ - Avoid infinite loops when hitting resolution bugs [#6722](https://github.com/rubygems/rubygems/pull/6722)
17
+ - Make `LockfileParser` usable with just a lockfile [#6694](https://github.com/rubygems/rubygems/pull/6694)
18
+ - Always rely on `$LOAD_PATH` when jumping from `exe/` to `lib/` [#6702](https://github.com/rubygems/rubygems/pull/6702)
19
+ - Make `frozen` setting take precedence over `deployment` setting [#6685](https://github.com/rubygems/rubygems/pull/6685)
20
+ - Show an error when trying to update bundler in frozen mode [#6684](https://github.com/rubygems/rubygems/pull/6684)
21
+
22
+ ## Bug fixes:
23
+
24
+ - Fix `deployment` vs `path` precedence [#6703](https://github.com/rubygems/rubygems/pull/6703)
25
+ - Fix inline mode with multiple sources [#6699](https://github.com/rubygems/rubygems/pull/6699)
26
+
27
+ # 2.4.13 (May 9, 2023)
28
+
29
+ ## Bug fixes:
30
+
31
+ - Fix unexpected fallbacks to full index by adding FalseClass and Time to the SafeMarshal list [#6655](https://github.com/rubygems/rubygems/pull/6655)
32
+
33
+ ## Documentation:
34
+
35
+ - Fix broken hyperlinks in bundle cache documentation [#6606](https://github.com/rubygems/rubygems/pull/6606)
36
+
37
+ # 2.4.12 (April 11, 2023)
38
+
39
+ ## Enhancements:
40
+
41
+ - Remove reference to `pry` gem from generated `bin/console` file [#6515](https://github.com/rubygems/rubygems/pull/6515)
42
+
43
+ # 2.4.11 (April 10, 2023)
44
+
45
+ ## Security:
46
+
47
+ - Use URI-0.12.1 (safe against CVE-2023-28755 ReDoS vulnerability) [#6558](https://github.com/rubygems/rubygems/pull/6558)
48
+
49
+ ## Enhancements:
50
+
51
+ - Remove one fallback to full indexes on big gemfiles [#6578](https://github.com/rubygems/rubygems/pull/6578)
52
+ - Generate native gems with `-fvisibility=hidden` [#6541](https://github.com/rubygems/rubygems/pull/6541)
53
+
54
+ ## Bug fixes:
55
+
56
+ - Fix resolver hangs when dealing with an incomplete lockfile [#6552](https://github.com/rubygems/rubygems/pull/6552)
57
+ - Fix prereleases not being considered by gem version promoter when there's no lockfile [#6537](https://github.com/rubygems/rubygems/pull/6537)
58
+
1
59
  # 2.4.10 (March 27, 2023)
2
60
 
3
61
  ## Bug fixes:
data/bundler/exe/bundle CHANGED
@@ -10,11 +10,11 @@ end
10
10
  base_path = File.expand_path("../lib", __dir__)
11
11
 
12
12
  if File.exist?(base_path)
13
- require_relative "../lib/bundler"
14
- else
15
- require "bundler"
13
+ $LOAD_PATH.unshift(base_path)
16
14
  end
17
15
 
16
+ require "bundler"
17
+
18
18
  if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::Version.new("2.7.a") && !ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"]
19
19
  Bundler.ui.warn \
20
20
  "Your RubyGems version (#{Gem::VERSION}) has a bug that prevents " \
@@ -24,18 +24,10 @@ if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::V
24
24
  "and silence this warning by running `gem update --system 3.2.3`"
25
25
  end
26
26
 
27
- if File.exist?(base_path)
28
- require_relative "../lib/bundler/friendly_errors"
29
- else
30
- require "bundler/friendly_errors"
31
- end
27
+ require "bundler/friendly_errors"
32
28
 
33
29
  Bundler.with_friendly_errors do
34
- if File.exist?(base_path)
35
- require_relative "../lib/bundler/cli"
36
- else
37
- require "bundler/cli"
38
- end
30
+ require "bundler/cli"
39
31
 
40
32
  # Allow any command to use --help flag to show help for that command
41
33
  help_flags = %w[--help -h]
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2023-03-27".freeze
8
- @git_commit_sha = "7ffdec80d0".freeze
7
+ @built_at = "2023-06-29".freeze
8
+ @git_commit_sha = "702f922bf2".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -76,8 +76,11 @@ module Bundler
76
76
 
77
77
  @lockfile = lockfile
78
78
  @lockfile_contents = String.new
79
+
79
80
  @locked_bundler_version = nil
80
- @locked_ruby_version = nil
81
+ @resolved_bundler_version = nil
82
+
83
+ @locked_ruby_version = nil
81
84
  @new_platform = nil
82
85
  @removed_platform = nil
83
86
 
@@ -146,7 +149,7 @@ module Bundler
146
149
  @dependency_changes = converge_dependencies
147
150
  @local_changes = converge_locals
148
151
 
149
- @incomplete_lockfile = check_missing_lockfile_specs
152
+ @missing_lockfile_dep = check_missing_lockfile_dep
150
153
  end
151
154
 
152
155
  def gem_version_promoter
@@ -217,6 +220,7 @@ module Bundler
217
220
  rescue BundlerError => e
218
221
  @resolve = nil
219
222
  @resolver = nil
223
+ @resolution_packages = nil
220
224
  @specs = nil
221
225
  @gem_version_promoter = nil
222
226
 
@@ -233,6 +237,14 @@ module Bundler
233
237
  end
234
238
 
235
239
  def current_dependencies
240
+ filter_relevant(dependencies)
241
+ end
242
+
243
+ def current_locked_dependencies
244
+ filter_relevant(locked_dependencies)
245
+ end
246
+
247
+ def filter_relevant(dependencies)
236
248
  dependencies.select do |d|
237
249
  d.should_include? && !d.gem_platforms([generic_local_platform]).empty?
238
250
  end
@@ -272,7 +284,7 @@ module Bundler
272
284
  @resolve ||= if Bundler.frozen_bundle?
273
285
  Bundler.ui.debug "Frozen, using resolution from the lockfile"
274
286
  @locked_specs
275
- elsif !unlocking? && nothing_changed?
287
+ elsif no_resolve_needed?
276
288
  if deleted_deps.any?
277
289
  Bundler.ui.debug "Some dependencies were deleted, using a subset of the resolution from the lockfile"
278
290
  SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps))
@@ -309,7 +321,7 @@ module Bundler
309
321
 
310
322
  if @locked_bundler_version
311
323
  locked_major = @locked_bundler_version.segments.first
312
- current_major = Bundler.gem_version.segments.first
324
+ current_major = bundler_version_to_lock.segments.first
313
325
 
314
326
  updating_major = locked_major < current_major
315
327
  end
@@ -349,27 +361,16 @@ module Bundler
349
361
  end
350
362
  end
351
363
 
364
+ def bundler_version_to_lock
365
+ @resolved_bundler_version || Bundler.gem_version
366
+ end
367
+
352
368
  def to_lock
353
369
  require_relative "lockfile_generator"
354
370
  LockfileGenerator.generate(self)
355
371
  end
356
372
 
357
373
  def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
358
- msg = String.new
359
- msg << "You are trying to install in deployment mode after changing\n" \
360
- "your Gemfile. Run `bundle install` elsewhere and add the\n" \
361
- "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
362
-
363
- unless explicit_flag
364
- suggested_command = if Bundler.settings.locations("frozen").keys.&([:global, :local]).any?
365
- "bundle config unset frozen"
366
- elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
367
- "bundle config unset deployment"
368
- end
369
- msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
370
- "freeze \nby running `#{suggested_command}`." if suggested_command
371
- end
372
-
373
374
  added = []
374
375
  deleted = []
375
376
  changed = []
@@ -383,13 +384,8 @@ module Bundler
383
384
  deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
384
385
 
385
386
  both_sources = Hash.new {|h, k| h[k] = [] }
386
- @dependencies.each {|d| both_sources[d.name][0] = d }
387
-
388
- locked_dependencies.each do |d|
389
- next if !Bundler.feature_flag.bundler_3_mode? && @locked_specs[d.name].empty?
390
-
391
- both_sources[d.name][1] = d
392
- end
387
+ current_dependencies.each {|d| both_sources[d.name][0] = d }
388
+ current_locked_dependencies.each {|d| both_sources[d.name][1] = d }
393
389
 
394
390
  both_sources.each do |name, (dep, lock_dep)|
395
391
  next if dep.nil? || lock_dep.nil?
@@ -404,11 +400,20 @@ module Bundler
404
400
  end
405
401
 
406
402
  reason = change_reason
407
- msg << "\n\n#{reason.split(", ").map(&:capitalize).join("\n")}" unless reason.strip.empty?
403
+ msg = String.new
404
+ msg << "#{reason.capitalize.strip}, but the lockfile can't be updated because frozen mode is set"
408
405
  msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
409
406
  msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
410
407
  msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
411
- msg << "\n"
408
+ msg << "\n\nRun `bundle install` elsewhere and add the updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control.\n"
409
+
410
+ unless explicit_flag
411
+ suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env)
412
+ "bundle config set frozen false"
413
+ end
414
+ msg << "If this is a development machine, remove the #{Bundler.default_gemfile.relative_path_from(SharedHelpers.pwd)} " \
415
+ "freeze by running `#{suggested_command}`." if suggested_command
416
+ end
412
417
 
413
418
  raise ProductionError, msg if added.any? || deleted.any? || changed.any? || !nothing_changed?
414
419
  end
@@ -473,7 +478,11 @@ module Bundler
473
478
  private :sources
474
479
 
475
480
  def nothing_changed?
476
- !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@incomplete_lockfile
481
+ !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@missing_lockfile_dep && !@unlocking_bundler
482
+ end
483
+
484
+ def no_resolve_needed?
485
+ !unlocking? && nothing_changed?
477
486
  end
478
487
 
479
488
  def unlocking?
@@ -487,7 +496,14 @@ module Bundler
487
496
  end
488
497
 
489
498
  def expanded_dependencies
490
- dependencies + metadata_dependencies
499
+ dependencies_with_bundler + metadata_dependencies
500
+ end
501
+
502
+ def dependencies_with_bundler
503
+ return dependencies unless @unlocking_bundler
504
+ return dependencies if dependencies.map(&:name).include?("bundler")
505
+
506
+ [Dependency.new("bundler", @unlocking_bundler)] + dependencies
491
507
  end
492
508
 
493
509
  def resolution_packages
@@ -553,6 +569,8 @@ module Bundler
553
569
  def start_resolution
554
570
  result = resolver.start
555
571
 
572
+ @resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version
573
+
556
574
  SpecSet.new(SpecSet.new(result).for(dependencies, false, @platforms))
557
575
  end
558
576
 
@@ -610,7 +628,8 @@ module Bundler
610
628
  [@new_platform, "you added a new platform to your gemfile"],
611
629
  [@path_changes, "the gemspecs for path gems changed"],
612
630
  [@local_changes, "the gemspecs for git local gems changed"],
613
- [@incomplete_lockfile, "your lock file is missing some gems"],
631
+ [@missing_lockfile_dep, "your lock file is missing \"#{@missing_lockfile_dep}\""],
632
+ [@unlocking_bundler, "an update to the version of Bundler itself was requested"],
614
633
  ].select(&:first).map(&:last).join(", ")
615
634
  end
616
635
 
@@ -665,12 +684,24 @@ module Bundler
665
684
  !sources_with_changes.each {|source| @unlock[:sources] << source.name }.empty?
666
685
  end
667
686
 
668
- def check_missing_lockfile_specs
687
+ def check_missing_lockfile_dep
669
688
  all_locked_specs = @locked_specs.map(&:name) << "bundler"
670
689
 
671
- @locked_specs.any? do |s|
690
+ missing = @locked_specs.select do |s|
672
691
  s.dependencies.any? {|dep| !all_locked_specs.include?(dep.name) }
673
692
  end
693
+
694
+ if missing.any?
695
+ @locked_specs.delete(missing)
696
+
697
+ return missing.first.name
698
+ end
699
+
700
+ return if @dependency_changes
701
+
702
+ current_dependencies.find do |d|
703
+ @locked_specs[d.name].empty?
704
+ end&.name
674
705
  end
675
706
 
676
707
  def converge_paths
@@ -854,8 +885,16 @@ module Bundler
854
885
  metadata_dependencies.each do |dep|
855
886
  source_requirements[dep.name] = sources.metadata_source
856
887
  end
857
- source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
858
- source_requirements["bundler"] = sources.metadata_source # needs to come last to override
888
+
889
+ default_bundler_source = source_requirements["bundler"] || sources.default_source
890
+
891
+ if @unlocking_bundler
892
+ default_bundler_source.add_dependency_names("bundler")
893
+ else
894
+ source_requirements[:default_bundler] = default_bundler_source
895
+ source_requirements["bundler"] = sources.metadata_source # needs to come last to override
896
+ end
897
+
859
898
  verify_changed_sources!
860
899
  source_requirements
861
900
  end
@@ -878,7 +917,8 @@ module Bundler
878
917
  if preserve_unknown_sections
879
918
  sections_to_ignore = LockfileParser.sections_to_ignore(@locked_bundler_version)
880
919
  sections_to_ignore += LockfileParser.unknown_sections_in_lockfile(current)
881
- sections_to_ignore += LockfileParser::ENVIRONMENT_VERSION_SECTIONS
920
+ sections_to_ignore << LockfileParser::RUBY
921
+ sections_to_ignore << LockfileParser::BUNDLED unless @unlocking_bundler
882
922
  pattern = /#{Regexp.union(sections_to_ignore)}\n(\s{2,}.*\n)+/
883
923
  whitespace_cleanup = /\n{2,}/
884
924
  current = current.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
@@ -93,7 +93,7 @@ module Bundler
93
93
  locked_version = package.locked_version
94
94
 
95
95
  result = specs.sort do |a, b|
96
- unless locked_version && (package.prerelease_specified? || pre?)
96
+ unless package.prerelease_specified? || pre?
97
97
  a_pre = a.prerelease?
98
98
  b_pre = b.prerelease?
99
99
 
@@ -90,7 +90,7 @@ module Bundler
90
90
 
91
91
  Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available
92
92
 
93
- lock unless Bundler.frozen_bundle?
93
+ lock
94
94
  Standalone.new(options[:standalone], @definition).generate if options[:standalone]
95
95
  end
96
96
  end
@@ -122,7 +122,7 @@ module Bundler
122
122
  end
123
123
 
124
124
  def to_s
125
- @__to_s ||= if platform == Gem::Platform::RUBY
125
+ @to_s ||= if platform == Gem::Platform::RUBY
126
126
  "#{name} (#{version})"
127
127
  else
128
128
  "#{name} (#{version}-#{platform})"
@@ -71,7 +71,7 @@ module Bundler
71
71
  end
72
72
 
73
73
  def add_bundled_with
74
- add_section("BUNDLED WITH", Bundler::VERSION)
74
+ add_section("BUNDLED WITH", definition.bundler_version_to_lock.to_s)
75
75
  end
76
76
 
77
77
  def add_section(name, value)
@@ -26,6 +26,7 @@ module Bundler
26
26
  KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten.freeze
27
27
 
28
28
  ENVIRONMENT_VERSION_SECTIONS = [BUNDLED, RUBY].freeze
29
+ deprecate_constant(:ENVIRONMENT_VERSION_SECTIONS)
29
30
 
30
31
  def self.sections_in_lockfile(lockfile_contents)
31
32
  lockfile_contents.scan(/^\w[\w ]*$/).uniq
@@ -13,7 +13,7 @@
13
13
  alias: \fBpackage\fR, \fBpack\fR
14
14
  .
15
15
  .SH "DESCRIPTION"
16
- Copy all of the \fB\.gem\fR files needed to run the application into the \fBvendor/cache\fR directory\. In the future, when running [bundle install(1)][bundle\-install], use the gems in the cache in preference to the ones on \fBrubygems\.org\fR\.
16
+ Copy all of the \fB\.gem\fR files needed to run the application into the \fBvendor/cache\fR directory\. In the future, when running \fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR, use the gems in the cache in preference to the ones on \fBrubygems\.org\fR\.
17
17
  .
18
18
  .SH "GIT AND PATH GEMS"
19
19
  The \fBbundle cache\fR command can also package \fB:git\fR and \fB:path\fR dependencies besides \.gem files\. This needs to be explicitly enabled via the \fB\-\-all\fR option\. Once used, the \fB\-\-all\fR option will be remembered\.
@@ -22,7 +22,7 @@ The \fBbundle cache\fR command can also package \fB:git\fR and \fB:path\fR depen
22
22
  When using gems that have different packages for different platforms, Bundler supports caching of gems for other platforms where the Gemfile has been resolved (i\.e\. present in the lockfile) in \fBvendor/cache\fR\. This needs to be enabled via the \fB\-\-all\-platforms\fR option\. This setting will be remembered in your local bundler configuration\.
23
23
  .
24
24
  .SH "REMOTE FETCHING"
25
- By default, if you run \fBbundle install(1)\fR](bundle\-install\.1\.html) after running bundle cache(1) \fIbundle\-cache\.1\.html\fR, bundler will still connect to \fBrubygems\.org\fR to check whether a platform\-specific gem exists for any of the gems in \fBvendor/cache\fR\.
25
+ By default, if you run \fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR after running bundle cache(1) \fIbundle\-cache\.1\.html\fR, bundler will still connect to \fBrubygems\.org\fR to check whether a platform\-specific gem exists for any of the gems in \fBvendor/cache\fR\.
26
26
  .
27
27
  .P
28
28
  For instance, consider this Gemfile(5):
@@ -10,7 +10,7 @@ alias: `package`, `pack`
10
10
  ## DESCRIPTION
11
11
 
12
12
  Copy all of the `.gem` files needed to run the application into the
13
- `vendor/cache` directory. In the future, when running [bundle install(1)][bundle-install],
13
+ `vendor/cache` directory. In the future, when running [`bundle install(1)`](bundle-install.1.html),
14
14
  use the gems in the cache in preference to the ones on `rubygems.org`.
15
15
 
16
16
  ## GIT AND PATH GEMS
@@ -29,7 +29,7 @@ bundler configuration.
29
29
 
30
30
  ## REMOTE FETCHING
31
31
 
32
- By default, if you run `bundle install(1)`](bundle-install.1.html) after running
32
+ By default, if you run [`bundle install(1)`](bundle-install.1.html) after running
33
33
  [bundle cache(1)](bundle-cache.1.html), bundler will still connect to `rubygems.org`
34
34
  to check whether a platform-specific gem exists for any of the gems
35
35
  in `vendor/cache`.
@@ -35,9 +35,7 @@ module Bundler
35
35
  end
36
36
 
37
37
  def delete(specs)
38
- specs.each do |spec|
39
- @base.delete(spec)
40
- end
38
+ @base.delete(specs)
41
39
  end
42
40
 
43
41
  def get_package(name)
@@ -160,7 +160,7 @@ module Bundler
160
160
  constraint_string = constraint.constraint_string
161
161
  requirements = constraint_string.split(" OR ").map {|req| Gem::Requirement.new(req.split(",")) }
162
162
 
163
- if name == "bundler"
163
+ if name == "bundler" && bundler_pinned_to_current_version?
164
164
  custom_explanation = "the current Bundler version (#{Bundler::VERSION}) does not satisfy #{constraint}"
165
165
  extended_explanation = bundler_not_found_message(requirements)
166
166
  else
@@ -230,6 +230,12 @@ module Bundler
230
230
  def all_versions_for(package)
231
231
  name = package.name
232
232
  results = (@base[name] + filter_prereleases(@all_specs[name], package)).uniq {|spec| [spec.version.hash, spec.platform] }
233
+
234
+ if name == "bundler" && !bundler_pinned_to_current_version?
235
+ bundler_spec = Gem.loaded_specs["bundler"]
236
+ results << bundler_spec if bundler_spec
237
+ end
238
+
233
239
  locked_requirement = base_requirements[name]
234
240
  results = filter_matching_specs(results, locked_requirement) if locked_requirement
235
241
 
@@ -254,6 +260,14 @@ module Bundler
254
260
  @source_requirements[name] || @source_requirements[:default]
255
261
  end
256
262
 
263
+ def default_bundler_source
264
+ @source_requirements[:default_bundler]
265
+ end
266
+
267
+ def bundler_pinned_to_current_version?
268
+ !default_bundler_source.nil?
269
+ end
270
+
257
271
  def name_for_explicit_dependency_source
258
272
  Bundler.default_gemfile.basename.to_s
259
273
  rescue StandardError
@@ -398,7 +412,7 @@ module Bundler
398
412
  end
399
413
 
400
414
  def bundler_not_found_message(conflict_dependencies)
401
- candidate_specs = filter_matching_specs(source_for(:default_bundler).specs.search("bundler"), conflict_dependencies)
415
+ candidate_specs = filter_matching_specs(default_bundler_source.specs.search("bundler"), conflict_dependencies)
402
416
 
403
417
  if candidate_specs.any?
404
418
  target_version = candidate_specs.last.version
@@ -107,7 +107,7 @@ module Bundler
107
107
  ruby_engine_version = RUBY_ENGINE == "ruby" ? ruby_version : RUBY_ENGINE_VERSION.dup
108
108
  patchlevel = RUBY_PATCHLEVEL.to_s
109
109
 
110
- @ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
110
+ @system ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
111
111
  end
112
112
 
113
113
  private
@@ -66,7 +66,9 @@ module Gem
66
66
 
67
67
  alias_method :rg_extension_dir, :extension_dir
68
68
  def extension_dir
69
- @bundler_extension_dir ||= if source.respond_to?(:extension_dir_name)
69
+ # following instance variable is already used in original method
70
+ # and that is the reason to prefix it with bundler_ and add rubocop exception
71
+ @bundler_extension_dir ||= if source.respond_to?(:extension_dir_name) # rubocop:disable Naming/MemoizedInstanceVariableName
70
72
  unique_extension_dir = [source.extension_dir_name, File.basename(full_gem_path)].uniq.join("-")
71
73
  File.expand_path(File.join(extensions_dir, unique_extension_dir))
72
74
  else
@@ -203,9 +205,9 @@ module Gem
203
205
  protected
204
206
 
205
207
  def _requirements_sorted?
206
- return @_are_requirements_sorted if defined?(@_are_requirements_sorted)
208
+ return @_requirements_sorted if defined?(@_requirements_sorted)
207
209
  strings = as_list
208
- @_are_requirements_sorted = strings == strings.sort
210
+ @_requirements_sorted = strings == strings.sort
209
211
  end
210
212
 
211
213
  def _with_sorted_requirements
@@ -94,7 +94,7 @@ module Bundler
94
94
  definition_method :requires
95
95
 
96
96
  def lock(opts = {})
97
- return if @definition.nothing_changed? && !@definition.unlocking?
97
+ return if @definition.no_resolve_needed?
98
98
  @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
99
99
  end
100
100