bundler 2.4.12 → 2.4.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +88 -0
  3. data/exe/bundle +5 -13
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli/binstubs.rb +1 -1
  6. data/lib/bundler/cli/info.rb +1 -1
  7. data/lib/bundler/cli/install.rb +1 -1
  8. data/lib/bundler/cli/outdated.rb +1 -1
  9. data/lib/bundler/cli/platform.rb +7 -5
  10. data/lib/bundler/definition.rb +97 -59
  11. data/lib/bundler/dsl.rb +1 -1
  12. data/lib/bundler/env.rb +1 -1
  13. data/lib/bundler/feature_flag.rb +0 -1
  14. data/lib/bundler/fetcher/compact_index.rb +3 -3
  15. data/lib/bundler/fetcher/downloader.rb +2 -0
  16. data/lib/bundler/fetcher/index.rb +1 -2
  17. data/lib/bundler/fetcher.rb +11 -1
  18. data/lib/bundler/friendly_errors.rb +1 -1
  19. data/lib/bundler/gem_helper.rb +3 -4
  20. data/lib/bundler/installer/parallel_installer.rb +1 -1
  21. data/lib/bundler/installer.rb +1 -1
  22. data/lib/bundler/lockfile_generator.rb +1 -1
  23. data/lib/bundler/lockfile_parser.rb +1 -0
  24. data/lib/bundler/man/bundle-add.1 +1 -1
  25. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  26. data/lib/bundler/man/bundle-cache.1 +3 -3
  27. data/lib/bundler/man/bundle-cache.1.ronn +2 -2
  28. data/lib/bundler/man/bundle-check.1 +1 -1
  29. data/lib/bundler/man/bundle-clean.1 +1 -1
  30. data/lib/bundler/man/bundle-config.1 +1 -4
  31. data/lib/bundler/man/bundle-config.1.ronn +0 -3
  32. data/lib/bundler/man/bundle-console.1 +1 -1
  33. data/lib/bundler/man/bundle-doctor.1 +1 -1
  34. data/lib/bundler/man/bundle-exec.1 +1 -1
  35. data/lib/bundler/man/bundle-gem.1 +1 -1
  36. data/lib/bundler/man/bundle-help.1 +1 -1
  37. data/lib/bundler/man/bundle-info.1 +3 -3
  38. data/lib/bundler/man/bundle-info.1.ronn +3 -3
  39. data/lib/bundler/man/bundle-init.1 +1 -1
  40. data/lib/bundler/man/bundle-inject.1 +1 -1
  41. data/lib/bundler/man/bundle-install.1 +1 -1
  42. data/lib/bundler/man/bundle-list.1 +1 -1
  43. data/lib/bundler/man/bundle-lock.1 +1 -1
  44. data/lib/bundler/man/bundle-open.1 +1 -1
  45. data/lib/bundler/man/bundle-outdated.1 +13 -9
  46. data/lib/bundler/man/bundle-outdated.1.ronn +12 -9
  47. data/lib/bundler/man/bundle-platform.1 +1 -1
  48. data/lib/bundler/man/bundle-plugin.1 +1 -1
  49. data/lib/bundler/man/bundle-pristine.1 +1 -1
  50. data/lib/bundler/man/bundle-remove.1 +1 -1
  51. data/lib/bundler/man/bundle-show.1 +1 -1
  52. data/lib/bundler/man/bundle-update.1 +1 -1
  53. data/lib/bundler/man/bundle-version.1 +1 -1
  54. data/lib/bundler/man/bundle-viz.1 +1 -1
  55. data/lib/bundler/man/bundle.1 +1 -1
  56. data/lib/bundler/man/gemfile.5 +15 -2
  57. data/lib/bundler/man/gemfile.5.ronn +6 -1
  58. data/lib/bundler/plugin/index.rb +1 -1
  59. data/lib/bundler/resolver.rb +16 -2
  60. data/lib/bundler/ruby_dsl.rb +6 -0
  61. data/lib/bundler/ruby_version.rb +2 -2
  62. data/lib/bundler/rubygems_integration.rb +1 -1
  63. data/lib/bundler/runtime.rb +1 -1
  64. data/lib/bundler/safe_marshal.rb +31 -0
  65. data/lib/bundler/settings.rb +3 -3
  66. data/lib/bundler/source/git/git_proxy.rb +31 -13
  67. data/lib/bundler/source/git.rb +40 -14
  68. data/lib/bundler/source/rubygems.rb +8 -5
  69. data/lib/bundler/source.rb +1 -1
  70. data/lib/bundler/source_list.rb +0 -4
  71. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  72. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +4 -4
  73. data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -1
  74. data/lib/bundler/ui/rg_proxy.rb +1 -1
  75. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1 -1
  76. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +9 -4
  77. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +2 -2
  78. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -1
  79. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  80. data/lib/bundler/version.rb +1 -1
  81. data/lib/bundler.rb +7 -15
  82. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6d97506b32368d35025b0ded439395a4f24b4d4f3936452d913a931d673f037
4
- data.tar.gz: 68f38a2de9040263c34db373ad83127a4209d62933d53a034422ce0db90cc611
3
+ metadata.gz: a9e1ac32a1ea746c717048bdfc433edc9d61cd2184f6d07b24e6addb565c1693
4
+ data.tar.gz: 95ab89a536022f9c642dd02683640819134441441dd0c4ae7b1cb0e9dd561a68
5
5
  SHA512:
6
- metadata.gz: 3da71fe39f4a4876346b73bcbb156223a6e21ce5445b797484dee2996753915b9960628b5fdaaadc357c51436e693b490092d9554a1c74906f69832b56bede2e
7
- data.tar.gz: 7646526addcdf4e8eea5cbfda0469bc609f1342a97653ded6dd245c0d1b5f434d2788ad9ad05e3e0fde5e80c02d3ed180a6e71d4c9093fd8b7fa068db47055b9
6
+ metadata.gz: 1cda1a2dfbdf88aaf7627304dc8fc740d3e4343b6d4f0e97a6473dc168b3b78c1128973251625beeee479a0418c25972f7dedb0cbcc9e107666fcdad32c991c8
7
+ data.tar.gz: e4589afe5650d8a937a2c56196221db8ce72d8cb91539ca0fceb9ad742d542ab4415b5253e6ffa3c8b03ccaac3dc6e8fe3b25d61cb17cd9155cc50d16dc44d4c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,91 @@
1
+ # 2.4.19 (August 17, 2023)
2
+
3
+ ## Enhancements:
4
+
5
+ - Add `file` option to `ruby` method in Gemfile [#6876](https://github.com/rubygems/rubygems/pull/6876)
6
+ - Show better error when PAT can't authenticate to a private server [#6871](https://github.com/rubygems/rubygems/pull/6871)
7
+ - Don't fallback to old dependency API when bad credentials are configured [#6869](https://github.com/rubygems/rubygems/pull/6869)
8
+
9
+ ## Bug fixes:
10
+
11
+ - Fix git source conservativeness [#6850](https://github.com/rubygems/rubygems/pull/6850)
12
+
13
+ ## Documentation:
14
+
15
+ - Clarify that `bundle info` takes a gem name [#6875](https://github.com/rubygems/rubygems/pull/6875)
16
+
17
+ # 2.4.18 (August 2, 2023)
18
+
19
+ ## Security:
20
+
21
+ - Merge URI-0.12.2 for Bundler [#6779](https://github.com/rubygems/rubygems/pull/6779)
22
+
23
+ ## Enhancements:
24
+
25
+ - Update Magnus version in Rust extension gem template [#6843](https://github.com/rubygems/rubygems/pull/6843)
26
+
27
+ ## Documentation:
28
+
29
+ - Update bundle-outdated(1) man to use table output [#6833](https://github.com/rubygems/rubygems/pull/6833)
30
+
31
+ # 2.4.17 (July 14, 2023)
32
+
33
+ ## Enhancements:
34
+
35
+ - Avoid printing "Using ..." messages when version has not changed [#6804](https://github.com/rubygems/rubygems/pull/6804)
36
+
37
+ ## Bug fixes:
38
+
39
+ - Fix `bundler/setup` unintendedly writing to the filesystem [#6814](https://github.com/rubygems/rubygems/pull/6814)
40
+
41
+ # 2.4.16 (July 10, 2023)
42
+
43
+ ## Bug fixes:
44
+
45
+ - Exclude Bundler from missing locked dependencies check [#6792](https://github.com/rubygems/rubygems/pull/6792)
46
+ - Fix another incorrect removal of "ruby" platform from lockfile when changing path sources [#6784](https://github.com/rubygems/rubygems/pull/6784)
47
+ - Fix git source lockfile instability [#6786](https://github.com/rubygems/rubygems/pull/6786)
48
+
49
+ ## Documentation:
50
+
51
+ - `gemfile.5`: Code format the default glob to escape Markdown [#6790](https://github.com/rubygems/rubygems/pull/6790)
52
+
53
+ # 2.4.15 (June 29, 2023)
54
+
55
+ ## Enhancements:
56
+
57
+ - Improve edge case error message [#6733](https://github.com/rubygems/rubygems/pull/6733)
58
+
59
+ ## Bug fixes:
60
+
61
+ - Fix `bundle lock --update --bundler` [#6213](https://github.com/rubygems/rubygems/pull/6213)
62
+
63
+ # 2.4.14 (June 12, 2023)
64
+
65
+ ## Enhancements:
66
+
67
+ - Stop publishing Gemfile in default gem template [#6723](https://github.com/rubygems/rubygems/pull/6723)
68
+ - Avoid infinite loops when hitting resolution bugs [#6722](https://github.com/rubygems/rubygems/pull/6722)
69
+ - Make `LockfileParser` usable with just a lockfile [#6694](https://github.com/rubygems/rubygems/pull/6694)
70
+ - Always rely on `$LOAD_PATH` when jumping from `exe/` to `lib/` [#6702](https://github.com/rubygems/rubygems/pull/6702)
71
+ - Make `frozen` setting take precedence over `deployment` setting [#6685](https://github.com/rubygems/rubygems/pull/6685)
72
+ - Show an error when trying to update bundler in frozen mode [#6684](https://github.com/rubygems/rubygems/pull/6684)
73
+
74
+ ## Bug fixes:
75
+
76
+ - Fix `deployment` vs `path` precedence [#6703](https://github.com/rubygems/rubygems/pull/6703)
77
+ - Fix inline mode with multiple sources [#6699](https://github.com/rubygems/rubygems/pull/6699)
78
+
79
+ # 2.4.13 (May 9, 2023)
80
+
81
+ ## Bug fixes:
82
+
83
+ - Fix unexpected fallbacks to full index by adding FalseClass and Time to the SafeMarshal list [#6655](https://github.com/rubygems/rubygems/pull/6655)
84
+
85
+ ## Documentation:
86
+
87
+ - Fix broken hyperlinks in bundle cache documentation [#6606](https://github.com/rubygems/rubygems/pull/6606)
88
+
1
89
  # 2.4.12 (April 11, 2023)
2
90
 
3
91
  ## Enhancements:
data/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-04-11".freeze
8
- @git_commit_sha = "e2cf278db1".freeze
7
+ @built_at = "2023-08-17".freeze
8
+ @git_commit_sha = "86f98098e3".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -11,7 +11,7 @@ module Bundler
11
11
  def run
12
12
  Bundler.definition.validate_runtime!
13
13
  path_option = options["path"]
14
- path_option = nil if path_option && path_option.empty?
14
+ path_option = nil if path_option&.empty?
15
15
  Bundler.settings.set_command_option :bin, path_option if options["path"]
16
16
  Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
17
17
  installer = Installer.new(Bundler.root, Bundler.definition)
@@ -33,7 +33,7 @@ module Bundler
33
33
  def default_gem_spec(gem_name)
34
34
  return unless Gem::Specification.respond_to?(:find_all_by_name)
35
35
  gem_spec = Gem::Specification.find_all_by_name(gem_name).last
36
- return gem_spec if gem_spec && gem_spec.respond_to?(:default_gem?) && gem_spec.default_gem?
36
+ return gem_spec if gem_spec&.default_gem?
37
37
  end
38
38
 
39
39
  def spec_not_found(gem_name)
@@ -154,7 +154,7 @@ module Bundler
154
154
  end
155
155
 
156
156
  bin_option = options["binstubs"]
157
- bin_option = nil if bin_option && bin_option.empty?
157
+ bin_option = nil if bin_option&.empty?
158
158
  Bundler.settings.set_command_option :bin, bin_option if options["binstubs"]
159
159
 
160
160
  Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
@@ -194,7 +194,7 @@ module Bundler
194
194
  end
195
195
  current_version = "#{current_spec.version}#{current_spec.git_version}"
196
196
 
197
- if dependency && dependency.specific?
197
+ if dependency&.specific?
198
198
  dependency_version = %(, requested #{dependency.requirement})
199
199
  end
200
200
 
@@ -8,12 +8,12 @@ module Bundler
8
8
  end
9
9
 
10
10
  def run
11
- platforms, ruby_version = Bundler.ui.silence do
12
- locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
13
- gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
14
- [Bundler.definition.platforms.map {|p| "* #{p}" },
15
- locked_ruby_version || gemfile_ruby_version]
11
+ ruby_version = if Bundler.locked_gems
12
+ Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
13
+ else
14
+ Bundler.definition.ruby_version&.single_version_string
16
15
  end
16
+
17
17
  output = []
18
18
 
19
19
  if options[:ruby]
@@ -23,6 +23,8 @@ module Bundler
23
23
  output << "No ruby version specified"
24
24
  end
25
25
  else
26
+ platforms = Bundler.definition.platforms.map {|p| "* #{p}" }
27
+
26
28
  output << "Your platform is: #{Gem::Platform.local}"
27
29
  output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
28
30
 
@@ -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,32 +384,36 @@ 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?
396
392
 
397
- gemfile_source = dep.source || sources.default_source
398
- lock_source = lock_dep.source || sources.default_source
393
+ gemfile_source = dep.source || default_source
394
+ lock_source = lock_dep.source || default_source
399
395
  next if lock_source.include?(gemfile_source)
400
396
 
401
- gemfile_source_name = dep.source ? gemfile_source.identifier : "no specified source"
402
- lockfile_source_name = lock_dep.source ? lock_source.identifier : "no specified source"
397
+ gemfile_source_name = dep.source ? gemfile_source.to_gemfile : "no specified source"
398
+ lockfile_source_name = lock_dep.source ? lock_source.to_gemfile : "no specified source"
403
399
  changed << "* #{name} from `#{lockfile_source_name}` to `#{gemfile_source_name}`"
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
 
@@ -652,8 +671,8 @@ module Bundler
652
671
 
653
672
  Bundler.settings.local_overrides.map do |k, v|
654
673
  spec = @dependencies.find {|s| s.name == k }
655
- source = spec && spec.source
656
- if source && source.respond_to?(:local_override!)
674
+ source = spec&.source
675
+ if source&.respond_to?(:local_override!)
657
676
  source.unlock! if @unlock[:gems].include?(spec.name)
658
677
  locals << [source, source.local_override!(v)]
659
678
  end
@@ -665,7 +684,7 @@ 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
690
  missing = @locked_specs.select do |s|
@@ -675,10 +694,14 @@ module Bundler
675
694
  if missing.any?
676
695
  @locked_specs.delete(missing)
677
696
 
678
- true
679
- else
680
- false
697
+ return missing.first.name
681
698
  end
699
+
700
+ return if @dependency_changes
701
+
702
+ current_dependencies.find do |d|
703
+ @locked_specs[d.name].empty? && d.name != "bundler"
704
+ end&.name
682
705
  end
683
706
 
684
707
  def converge_paths
@@ -782,26 +805,27 @@ module Bundler
782
805
 
783
806
  def converge_specs(specs)
784
807
  converged = []
785
-
786
- deps = @dependencies.select do |dep|
787
- specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
788
- end
808
+ deps = []
789
809
 
790
810
  @specs_that_changed_sources = []
791
811
 
792
812
  specs.each do |s|
813
+ name = s.name
793
814
  dep = @dependencies.find {|d| s.satisfies?(d) }
815
+ lockfile_source = s.source
794
816
 
795
- # Replace the locked dependency's source with the equivalent source from the Gemfile
796
- s.source = if dep && dep.source
797
- gemfile_source = dep.source
798
- lockfile_source = s.source
817
+ if dep
818
+ gemfile_source = dep.source || default_source
799
819
 
800
820
  @specs_that_changed_sources << s if gemfile_source != lockfile_source
821
+ deps << dep if !dep.source || lockfile_source.include?(dep.source)
822
+ @unlock[:gems] << name if lockfile_source.include?(dep.source) && lockfile_source != gemfile_source
801
823
 
802
- gemfile_source
824
+ # Replace the locked dependency's source with the equivalent source from the Gemfile
825
+ s.source = gemfile_source
803
826
  else
804
- sources.get_with_fallback(s.source)
827
+ # Replace the locked dependency's source with the default source, if the locked source is no longer in the Gemfile
828
+ s.source = default_source unless sources.get(lockfile_source)
805
829
  end
806
830
 
807
831
  next if @unlock[:sources].include?(s.source.name)
@@ -810,9 +834,9 @@ module Bundler
810
834
  if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
811
835
  new_specs = begin
812
836
  s.source.specs
813
- rescue PathError, GitError
837
+ rescue PathError
814
838
  # if we won't need the source (according to the lockfile),
815
- # don't error if the path/git source isn't available
839
+ # don't error if the path source isn't available
816
840
  next if specs.
817
841
  for(requested_dependencies, false).
818
842
  none? {|locked_spec| locked_spec.source == s.source }
@@ -826,11 +850,11 @@ module Bundler
826
850
  else
827
851
  # If the spec is no longer in the path source, unlock it. This
828
852
  # commonly happens if the version changed in the gemspec
829
- @unlock[:gems] << s.name
853
+ @unlock[:gems] << name
830
854
  end
831
855
  end
832
856
 
833
- if dep.nil? && requested_dependencies.find {|d| s.name == d.name }
857
+ if dep.nil? && requested_dependencies.find {|d| name == d.name }
834
858
  @unlock[:gems] << s.name
835
859
  else
836
860
  converged << s
@@ -854,7 +878,7 @@ module Bundler
854
878
  source_requirements = if precompute_source_requirements_for_indirect_dependencies?
855
879
  all_requirements = source_map.all_requirements
856
880
  all_requirements = pin_locally_available_names(all_requirements) if @prefer_local
857
- { :default => sources.default_source }.merge(all_requirements)
881
+ { :default => default_source }.merge(all_requirements)
858
882
  else
859
883
  { :default => Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
860
884
  end
@@ -862,12 +886,24 @@ module Bundler
862
886
  metadata_dependencies.each do |dep|
863
887
  source_requirements[dep.name] = sources.metadata_source
864
888
  end
865
- source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
866
- source_requirements["bundler"] = sources.metadata_source # needs to come last to override
889
+
890
+ default_bundler_source = source_requirements["bundler"] || default_source
891
+
892
+ if @unlocking_bundler
893
+ default_bundler_source.add_dependency_names("bundler")
894
+ else
895
+ source_requirements[:default_bundler] = default_bundler_source
896
+ source_requirements["bundler"] = sources.metadata_source # needs to come last to override
897
+ end
898
+
867
899
  verify_changed_sources!
868
900
  source_requirements
869
901
  end
870
902
 
903
+ def default_source
904
+ sources.default_source
905
+ end
906
+
871
907
  def verify_changed_sources!
872
908
  @specs_that_changed_sources.each do |s|
873
909
  if s.source.specs.search(s.name).empty?
@@ -886,7 +922,8 @@ module Bundler
886
922
  if preserve_unknown_sections
887
923
  sections_to_ignore = LockfileParser.sections_to_ignore(@locked_bundler_version)
888
924
  sections_to_ignore += LockfileParser.unknown_sections_in_lockfile(current)
889
- sections_to_ignore += LockfileParser::ENVIRONMENT_VERSION_SECTIONS
925
+ sections_to_ignore << LockfileParser::RUBY
926
+ sections_to_ignore << LockfileParser::BUNDLED unless @unlocking_bundler
890
927
  pattern = /#{Regexp.union(sections_to_ignore)}\n(\s{2,}.*\n)+/
891
928
  whitespace_cleanup = /\n{2,}/
892
929
  current = current.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
@@ -909,6 +946,7 @@ module Bundler
909
946
  Bundler.local_platform == Gem::Platform::RUBY ||
910
947
  !platforms.include?(Gem::Platform::RUBY) ||
911
948
  (@new_platform && platforms.last == Gem::Platform::RUBY) ||
949
+ @path_changes ||
912
950
  @dependency_changes ||
913
951
  !@originally_locked_specs.incomplete_ruby_specs?(dependencies)
914
952
 
data/lib/bundler/dsl.rb CHANGED
@@ -41,7 +41,7 @@ module Bundler
41
41
  end
42
42
 
43
43
  def eval_gemfile(gemfile, contents = nil)
44
- expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile && @gemfile.parent)
44
+ expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile&.parent)
45
45
  original_gemfile = @gemfile
46
46
  @gemfile = expanded_gemfile_path
47
47
  @gemfiles << expanded_gemfile_path
data/lib/bundler/env.rb CHANGED
@@ -122,7 +122,7 @@ module Bundler
122
122
  specs = Bundler.rubygems.find_name(name)
123
123
  out << [" #{name}", "(#{specs.map(&:version).join(",")})"] unless specs.empty?
124
124
  end
125
- if (exe = caller.last.split(":").first) && exe =~ %r{(exe|bin)/bundler?\z}
125
+ if (exe = caller.last.split(":").first)&.match? %r{(exe|bin)/bundler?\z}
126
126
  shebang = File.read(exe).lines.first
127
127
  shebang.sub!(/^#!\s*/, "")
128
128
  unless shebang.start_with?(Gem.ruby, "/usr/bin/env ruby")
@@ -37,7 +37,6 @@ module Bundler
37
37
  settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
38
38
  settings_flag(:print_only_version_number) { bundler_3_mode? }
39
39
  settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? }
40
- settings_flag(:suppress_install_using_messages) { bundler_3_mode? }
41
40
  settings_flag(:update_requires_all_flag) { bundler_4_mode? }
42
41
 
43
42
  settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install }
@@ -15,7 +15,7 @@ module Bundler
15
15
  method.bind(self).call(*args, &blk)
16
16
  rescue NetworkDownError, CompactIndexClient::Updater::MisMatchedChecksumError => e
17
17
  raise HTTPError, e.message
18
- rescue AuthenticationRequiredError
18
+ rescue AuthenticationRequiredError, BadAuthenticationError
19
19
  # Fail since we got a 401 from the server.
20
20
  raise
21
21
  rescue HTTPError => e
@@ -40,7 +40,7 @@ module Bundler
40
40
  deps = begin
41
41
  parallel_compact_index_client.dependencies(remaining_gems)
42
42
  rescue TooManyRequestsError
43
- @bundle_worker.stop if @bundle_worker
43
+ @bundle_worker&.stop
44
44
  @bundle_worker = nil # reset it. Not sure if necessary
45
45
  serial_compact_index_client.dependencies(remaining_gems)
46
46
  end
@@ -49,7 +49,7 @@ module Bundler
49
49
  complete_gems.concat(deps.map(&:first)).uniq!
50
50
  remaining_gems = next_gems - complete_gems
51
51
  end
52
- @bundle_worker.stop if @bundle_worker
52
+ @bundle_worker&.stop
53
53
  @bundle_worker = nil # reset it. Not sure if necessary
54
54
 
55
55
  gem_info
@@ -41,6 +41,8 @@ module Bundler
41
41
  when Net::HTTPUnauthorized
42
42
  raise BadAuthenticationError, uri.host if uri.userinfo
43
43
  raise AuthenticationRequiredError, uri.host
44
+ when Net::HTTPForbidden
45
+ raise AuthenticationForbiddenError, uri.host
44
46
  when Net::HTTPNotFound
45
47
  raise FallbackError, "Net::HTTPNotFound: #{filtered_uri}"
46
48
  else
@@ -15,8 +15,7 @@ module Bundler
15
15
  raise BadAuthenticationError, remote_uri if remote_uri.userinfo
16
16
  raise AuthenticationRequiredError, remote_uri
17
17
  when /403/
18
- raise BadAuthenticationError, remote_uri if remote_uri.userinfo
19
- raise AuthenticationRequiredError, remote_uri
18
+ raise AuthenticationForbiddenError, remote_uri
20
19
  else
21
20
  raise HTTPError, "Could not fetch specs from #{display_uri} due to underlying error <#{e.message}>"
22
21
  end
@@ -61,6 +61,16 @@ module Bundler
61
61
  end
62
62
  end
63
63
 
64
+ # This error is raised if HTTP authentication is correct, but lacks
65
+ # necessary permissions.
66
+ class AuthenticationForbiddenError < HTTPError
67
+ def initialize(remote_uri)
68
+ remote_uri = filter_uri(remote_uri)
69
+ super "Access token could not be authenticated for #{remote_uri}.\n" \
70
+ "Make sure it's valid and has the necessary scopes configured."
71
+ end
72
+ end
73
+
64
74
  # Exceptions classes that should bypass retry attempts. If your password didn't work the
65
75
  # first time, it's not going to the third time.
66
76
  NET_ERRORS = [:HTTPBadGateway, :HTTPBadRequest, :HTTPFailedDependency,
@@ -70,7 +80,7 @@ module Bundler
70
80
  :HTTPRequestURITooLong, :HTTPUnauthorized, :HTTPUnprocessableEntity,
71
81
  :HTTPUnsupportedMediaType, :HTTPVersionNotSupported].freeze
72
82
  FAIL_ERRORS = begin
73
- fail_errors = [AuthenticationRequiredError, BadAuthenticationError, FallbackError]
83
+ fail_errors = [AuthenticationRequiredError, BadAuthenticationError, AuthenticationForbiddenError, FallbackError]
74
84
  fail_errors << Gem::Requirement::BadRequirementError
75
85
  fail_errors.concat(NET_ERRORS.map {|e| Net.const_get(e) })
76
86
  end.freeze