bundler 2.6.5 → 2.7.1

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 (136) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1172 -1024
  3. data/README.md +7 -7
  4. data/bundler.gemspec +2 -2
  5. data/lib/bundler/build_metadata.rb +10 -11
  6. data/lib/bundler/checksum.rb +22 -12
  7. data/lib/bundler/cli/common.rb +1 -1
  8. data/lib/bundler/cli/config.rb +2 -2
  9. data/lib/bundler/cli/doctor/diagnose.rb +167 -0
  10. data/lib/bundler/cli/doctor/ssl.rb +249 -0
  11. data/lib/bundler/cli/doctor.rb +27 -155
  12. data/lib/bundler/cli/gem.rb +62 -30
  13. data/lib/bundler/cli/inject.rb +2 -2
  14. data/lib/bundler/cli/install.rb +5 -5
  15. data/lib/bundler/cli/issue.rb +2 -2
  16. data/lib/bundler/cli/lock.rb +2 -1
  17. data/lib/bundler/cli/outdated.rb +1 -1
  18. data/lib/bundler/cli/update.rb +3 -3
  19. data/lib/bundler/cli.rb +26 -49
  20. data/lib/bundler/compact_index_client/cache.rb +1 -1
  21. data/lib/bundler/compact_index_client/parser.rb +1 -1
  22. data/lib/bundler/compact_index_client/updater.rb +2 -1
  23. data/lib/bundler/compact_index_client.rb +1 -5
  24. data/lib/bundler/current_ruby.rb +27 -3
  25. data/lib/bundler/definition.rb +184 -151
  26. data/lib/bundler/dependency.rb +1 -1
  27. data/lib/bundler/dsl.rb +35 -26
  28. data/lib/bundler/errors.rb +18 -0
  29. data/lib/bundler/feature_flag.rb +15 -12
  30. data/lib/bundler/fetcher/dependency.rb +2 -1
  31. data/lib/bundler/fetcher/downloader.rb +33 -7
  32. data/lib/bundler/fetcher.rb +49 -19
  33. data/lib/bundler/friendly_errors.rb +3 -2
  34. data/lib/bundler/index.rb +7 -2
  35. data/lib/bundler/injector.rb +9 -9
  36. data/lib/bundler/installer.rb +6 -5
  37. data/lib/bundler/lazy_specification.rb +38 -19
  38. data/lib/bundler/lockfile_parser.rb +29 -10
  39. data/lib/bundler/man/bundle-add.1 +1 -1
  40. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  41. data/lib/bundler/man/bundle-cache.1 +1 -1
  42. data/lib/bundler/man/bundle-check.1 +1 -1
  43. data/lib/bundler/man/bundle-clean.1 +1 -1
  44. data/lib/bundler/man/bundle-config.1 +175 -129
  45. data/lib/bundler/man/bundle-config.1.ronn +93 -88
  46. data/lib/bundler/man/bundle-console.1 +1 -1
  47. data/lib/bundler/man/bundle-doctor.1 +43 -4
  48. data/lib/bundler/man/bundle-doctor.1.ronn +48 -4
  49. data/lib/bundler/man/bundle-env.1 +1 -1
  50. data/lib/bundler/man/bundle-exec.1 +3 -3
  51. data/lib/bundler/man/bundle-exec.1.ronn +2 -2
  52. data/lib/bundler/man/bundle-fund.1 +1 -1
  53. data/lib/bundler/man/bundle-gem.1 +67 -44
  54. data/lib/bundler/man/bundle-gem.1.ronn +8 -4
  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-inject.1 +2 -2
  59. data/lib/bundler/man/bundle-inject.1.ronn +1 -1
  60. data/lib/bundler/man/bundle-install.1 +4 -4
  61. data/lib/bundler/man/bundle-install.1.ronn +3 -4
  62. data/lib/bundler/man/bundle-issue.1 +1 -1
  63. data/lib/bundler/man/bundle-licenses.1 +1 -1
  64. data/lib/bundler/man/bundle-list.1 +1 -1
  65. data/lib/bundler/man/bundle-lock.1 +1 -1
  66. data/lib/bundler/man/bundle-open.1 +1 -1
  67. data/lib/bundler/man/bundle-outdated.1 +1 -1
  68. data/lib/bundler/man/bundle-platform.1 +1 -1
  69. data/lib/bundler/man/bundle-plugin.1 +1 -1
  70. data/lib/bundler/man/bundle-pristine.1 +1 -1
  71. data/lib/bundler/man/bundle-remove.1 +1 -1
  72. data/lib/bundler/man/bundle-show.1 +1 -1
  73. data/lib/bundler/man/bundle-update.1 +5 -5
  74. data/lib/bundler/man/bundle-update.1.ronn +4 -4
  75. data/lib/bundler/man/bundle-version.1 +1 -1
  76. data/lib/bundler/man/bundle-viz.1 +1 -1
  77. data/lib/bundler/man/bundle.1 +1 -1
  78. data/lib/bundler/man/gemfile.5 +1 -1
  79. data/lib/bundler/match_platform.rb +31 -12
  80. data/lib/bundler/materialization.rb +2 -2
  81. data/lib/bundler/plugin/api/source.rb +1 -1
  82. data/lib/bundler/plugin/index.rb +1 -1
  83. data/lib/bundler/plugin/installer/path.rb +8 -0
  84. data/lib/bundler/plugin.rb +1 -1
  85. data/lib/bundler/resolver/candidate.rb +12 -9
  86. data/lib/bundler/resolver/package.rb +1 -1
  87. data/lib/bundler/resolver/strategy.rb +40 -0
  88. data/lib/bundler/resolver.rb +18 -27
  89. data/lib/bundler/rubygems_ext.rb +131 -120
  90. data/lib/bundler/rubygems_integration.rb +11 -6
  91. data/lib/bundler/runtime.rb +9 -6
  92. data/lib/bundler/self_manager.rb +32 -42
  93. data/lib/bundler/settings/validator.rb +0 -23
  94. data/lib/bundler/settings.rb +4 -6
  95. data/lib/bundler/shared_helpers.rb +10 -4
  96. data/lib/bundler/source/gemspec.rb +1 -4
  97. data/lib/bundler/source/git/git_proxy.rb +17 -6
  98. data/lib/bundler/source/git.rb +5 -1
  99. data/lib/bundler/source/path.rb +9 -2
  100. data/lib/bundler/source/rubygems/remote.rb +11 -3
  101. data/lib/bundler/source_list.rb +30 -16
  102. data/lib/bundler/source_map.rb +1 -1
  103. data/lib/bundler/spec_set.rb +55 -16
  104. data/lib/bundler/templates/Executable +0 -11
  105. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +2 -0
  106. data/lib/bundler/templates/newgem/newgem.gemspec.tt +6 -5
  107. data/lib/bundler/ui/shell.rb +2 -2
  108. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +53 -3
  109. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  110. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +11 -0
  111. data/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  112. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +2 -1
  113. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +81 -42
  114. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +4 -24
  115. data/lib/bundler/vendor/pub_grub/lib/pub_grub/strategy.rb +42 -0
  116. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +20 -8
  117. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +17 -29
  118. data/lib/bundler/vendor/uri/lib/uri/common.rb +7 -3
  119. data/lib/bundler/vendor/uri/lib/uri/generic.rb +12 -11
  120. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +6 -6
  121. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  122. data/lib/bundler/version.rb +10 -2
  123. data/lib/bundler/worker.rb +1 -1
  124. data/lib/bundler.rb +14 -12
  125. metadata +9 -16
  126. data/lib/bundler/compact_index_client/gem_parser.rb +0 -32
  127. data/lib/bundler/gem_helpers.rb +0 -144
  128. data/lib/bundler/templates/Executable.bundler +0 -109
  129. data/lib/bundler/vendor/connection_pool/.document +0 -1
  130. data/lib/bundler/vendor/fileutils/.document +0 -1
  131. data/lib/bundler/vendor/net-http-persistent/.document +0 -1
  132. data/lib/bundler/vendor/pub_grub/.document +0 -1
  133. data/lib/bundler/vendor/securerandom/.document +0 -1
  134. data/lib/bundler/vendor/thor/.document +0 -1
  135. data/lib/bundler/vendor/tsort/.document +0 -1
  136. data/lib/bundler/vendor/uri/.document +0 -1
@@ -13,15 +13,6 @@ require "rubygems" unless defined?(Gem)
13
13
  # `Gem::Source` from the redefined `Gem::Specification#source`.
14
14
  require "rubygems/source"
15
15
 
16
- # Cherry-pick fixes to `Gem.ruby_version` to be useful for modern Bundler
17
- # versions and ignore patchlevels
18
- # (https://github.com/rubygems/rubygems/pull/5472,
19
- # https://github.com/rubygems/rubygems/pull/5486). May be removed once RubyGems
20
- # 3.3.12 support is dropped.
21
- unless Gem.ruby_version.to_s == RUBY_VERSION || RUBY_PATCHLEVEL == -1
22
- Gem.instance_variable_set(:@ruby_version, Gem::Version.new(RUBY_VERSION))
23
- end
24
-
25
16
  module Gem
26
17
  # Can be removed once RubyGems 3.5.11 support is dropped
27
18
  unless Gem.respond_to?(:freebsd_platform?)
@@ -61,81 +52,122 @@ module Gem
61
52
  require "rubygems/platform"
62
53
 
63
54
  class Platform
64
- JAVA = Gem::Platform.new("java")
65
- MSWIN = Gem::Platform.new("mswin32")
66
- MSWIN64 = Gem::Platform.new("mswin64")
67
- MINGW = Gem::Platform.new("x86-mingw32")
68
- X64_MINGW = [Gem::Platform.new("x64-mingw32"),
69
- Gem::Platform.new("x64-mingw-ucrt")].freeze
70
- UNIVERSAL_MINGW = Gem::Platform.new("universal-mingw")
71
- WINDOWS = [MSWIN, MSWIN64, UNIVERSAL_MINGW].flatten.freeze
72
- X64_LINUX = Gem::Platform.new("x86_64-linux")
73
- X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl")
74
-
75
- if X64_LINUX === X64_LINUX_MUSL
76
- remove_method :===
77
-
78
- def ===(other)
79
- return nil unless Gem::Platform === other
80
-
81
- # universal-mingw32 matches x64-mingw-ucrt
82
- return true if (@cpu == "universal" || other.cpu == "universal") &&
83
- @os.start_with?("mingw") && other.os.start_with?("mingw")
84
-
85
- # cpu
86
- ([nil,"universal"].include?(@cpu) || [nil, "universal"].include?(other.cpu) || @cpu == other.cpu ||
87
- (@cpu == "arm" && other.cpu.start_with?("armv"))) &&
88
-
89
- # os
90
- @os == other.os &&
91
-
92
- # version
93
- (
94
- (@os != "linux" && (@version.nil? || other.version.nil?)) ||
95
- (@os == "linux" && (normalized_linux_version_ext == other.normalized_linux_version_ext || ["musl#{@version}", "musleabi#{@version}", "musleabihf#{@version}"].include?(other.version))) ||
96
- @version == other.version
97
- )
98
- end
55
+ # Can be removed once RubyGems 3.6.9 support is dropped
56
+ unless respond_to?(:generic)
57
+ JAVA = Gem::Platform.new("java") # :nodoc:
58
+ MSWIN = Gem::Platform.new("mswin32") # :nodoc:
59
+ MSWIN64 = Gem::Platform.new("mswin64") # :nodoc:
60
+ MINGW = Gem::Platform.new("x86-mingw32") # :nodoc:
61
+ X64_MINGW_LEGACY = Gem::Platform.new("x64-mingw32") # :nodoc:
62
+ X64_MINGW = Gem::Platform.new("x64-mingw-ucrt") # :nodoc:
63
+ UNIVERSAL_MINGW = Gem::Platform.new("universal-mingw") # :nodoc:
64
+ WINDOWS = [MSWIN, MSWIN64, UNIVERSAL_MINGW].freeze # :nodoc:
65
+ X64_LINUX = Gem::Platform.new("x86_64-linux") # :nodoc:
66
+ X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl") # :nodoc:
67
+
68
+ GENERICS = [JAVA, *WINDOWS].freeze # :nodoc:
69
+ private_constant :GENERICS
70
+
71
+ GENERIC_CACHE = GENERICS.each_with_object({}) {|g, h| h[g] = g } # :nodoc:
72
+ private_constant :GENERIC_CACHE
99
73
 
100
- # This is a copy of RubyGems 3.3.23 or higher `normalized_linux_method`.
101
- # Once only 3.3.23 is supported, we can use the method in RubyGems.
102
- def normalized_linux_version_ext
103
- return nil unless @version
74
+ class << self
75
+ ##
76
+ # Returns the generic platform for the given platform.
104
77
 
105
- without_gnu_nor_abi_modifiers = @version.sub(/\Agnu/, "").sub(/eabi(hf)?\Z/, "")
106
- return nil if without_gnu_nor_abi_modifiers.empty?
78
+ def generic(platform)
79
+ return Gem::Platform::RUBY if platform.nil? || platform == Gem::Platform::RUBY
107
80
 
108
- without_gnu_nor_abi_modifiers
109
- end
110
- end
111
- end
81
+ GENERIC_CACHE[platform] ||= begin
82
+ found = GENERICS.find do |match|
83
+ platform === match
84
+ end
85
+ found || Gem::Platform::RUBY
86
+ end
87
+ end
112
88
 
113
- Platform.singleton_class.module_eval do
114
- unless Platform.singleton_methods.include?(:match_spec?)
115
- def match_spec?(spec)
116
- match_gem?(spec.platform, spec.name)
117
- end
89
+ ##
90
+ # Returns the platform specificity match for the given spec platform and user platform.
118
91
 
119
- def match_gem?(platform, gem_name)
120
- match_platforms?(platform, Gem.platforms)
121
- end
122
- end
92
+ def platform_specificity_match(spec_platform, user_platform)
93
+ return -1 if spec_platform == user_platform
94
+ return 1_000_000 if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY
95
+
96
+ os_match(spec_platform, user_platform) +
97
+ cpu_match(spec_platform, user_platform) * 10 +
98
+ version_match(spec_platform, user_platform) * 100
99
+ end
100
+
101
+ ##
102
+ # Sorts and filters the best platform match for the given matching specs and platform.
103
+
104
+ def sort_and_filter_best_platform_match(matching, platform)
105
+ return matching if matching.one?
106
+
107
+ exact = matching.select {|spec| spec.platform == platform }
108
+ return exact if exact.any?
123
109
 
124
- match_platforms_defined = Gem::Platform.respond_to?(:match_platforms?, true)
110
+ sorted_matching = sort_best_platform_match(matching, platform)
111
+ exemplary_spec = sorted_matching.first
125
112
 
126
- if !match_platforms_defined || Gem::Platform.send(:match_platforms?, Gem::Platform::X64_LINUX_MUSL, [Gem::Platform::X64_LINUX])
113
+ sorted_matching.take_while {|spec| same_specificity?(platform, spec, exemplary_spec) && same_deps?(spec, exemplary_spec) }
114
+ end
127
115
 
128
- private
116
+ ##
117
+ # Sorts the best platform match for the given matching specs and platform.
129
118
 
130
- remove_method :match_platforms? if match_platforms_defined
119
+ def sort_best_platform_match(matching, platform)
120
+ matching.sort_by.with_index do |spec, i|
121
+ [
122
+ platform_specificity_match(spec.platform, platform),
123
+ i, # for stable sort
124
+ ]
125
+ end
126
+ end
131
127
 
132
- def match_platforms?(platform, platforms)
133
- platforms.any? do |local_platform|
134
- platform.nil? ||
135
- local_platform == platform ||
136
- (local_platform != Gem::Platform::RUBY && platform =~ local_platform)
128
+ private
129
+
130
+ def same_specificity?(platform, spec, exemplary_spec)
131
+ platform_specificity_match(spec.platform, platform) == platform_specificity_match(exemplary_spec.platform, platform)
132
+ end
133
+
134
+ def same_deps?(spec, exemplary_spec)
135
+ spec.required_ruby_version == exemplary_spec.required_ruby_version &&
136
+ spec.required_rubygems_version == exemplary_spec.required_rubygems_version &&
137
+ spec.dependencies.sort == exemplary_spec.dependencies.sort
138
+ end
139
+
140
+ def os_match(spec_platform, user_platform)
141
+ if spec_platform.os == user_platform.os
142
+ 0
143
+ else
144
+ 1
145
+ end
146
+ end
147
+
148
+ def cpu_match(spec_platform, user_platform)
149
+ if spec_platform.cpu == user_platform.cpu
150
+ 0
151
+ elsif spec_platform.cpu == "arm" && user_platform.cpu.to_s.start_with?("arm")
152
+ 0
153
+ elsif spec_platform.cpu.nil? || spec_platform.cpu == "universal"
154
+ 1
155
+ else
156
+ 2
157
+ end
158
+ end
159
+
160
+ def version_match(spec_platform, user_platform)
161
+ if spec_platform.version == user_platform.version
162
+ 0
163
+ elsif spec_platform.version.nil?
164
+ 1
165
+ else
166
+ 2
167
+ end
137
168
  end
138
169
  end
170
+
139
171
  end
140
172
  end
141
173
 
@@ -144,9 +176,6 @@ module Gem
144
176
  # Can be removed once RubyGems 3.5.14 support is dropped
145
177
  VALIDATES_FOR_RESOLUTION = Specification.new.respond_to?(:validate_for_resolution).freeze
146
178
 
147
- # Can be removed once RubyGems 3.3.15 support is dropped
148
- FLATTENS_REQUIRED_PATHS = Specification.new.respond_to?(:flatten_require_paths).freeze
149
-
150
179
  class Specification
151
180
  # Can be removed once RubyGems 3.5.15 support is dropped
152
181
  correct_array_attributes = @@default_value.select {|_k,v| v.is_a?(Array) }.keys
@@ -158,7 +187,6 @@ module Gem
158
187
  require_relative "match_platform"
159
188
 
160
189
  include ::Bundler::MatchMetadata
161
- include ::Bundler::MatchPlatform
162
190
 
163
191
  attr_accessor :remote, :relative_loaded_from
164
192
 
@@ -214,23 +242,6 @@ module Gem
214
242
  full_gem_path
215
243
  end
216
244
 
217
- unless const_defined?(:LATEST_RUBY_WITHOUT_PATCH_VERSIONS)
218
- LATEST_RUBY_WITHOUT_PATCH_VERSIONS = Gem::Version.new("2.1")
219
-
220
- alias_method :rg_required_ruby_version=, :required_ruby_version=
221
- def required_ruby_version=(req)
222
- self.rg_required_ruby_version = req
223
-
224
- @required_ruby_version.requirements.map! do |op, v|
225
- if v >= LATEST_RUBY_WITHOUT_PATCH_VERSIONS && v.release.segments.size == 4
226
- [op == "~>" ? "=" : op, Gem::Version.new(v.segments.tap {|s| s.delete_at(3) }.join("."))]
227
- else
228
- [op, v]
229
- end
230
- end
231
- end
232
- end
233
-
234
245
  def insecurely_materialized?
235
246
  false
236
247
  end
@@ -262,31 +273,26 @@ module Gem
262
273
  !default_gem? && !File.directory?(full_gem_path)
263
274
  end
264
275
 
276
+ def lock_name
277
+ @lock_name ||= name_tuple.lock_name
278
+ end
279
+
265
280
  unless VALIDATES_FOR_RESOLUTION
266
281
  def validate_for_resolution
267
282
  SpecificationPolicy.new(self).validate_for_resolution
268
283
  end
269
284
  end
270
285
 
271
- unless FLATTENS_REQUIRED_PATHS
272
- def flatten_require_paths
273
- return unless raw_require_paths.first.is_a?(Array)
274
-
275
- warn "#{name} #{version} includes a gemspec with `require_paths` set to an array of arrays. Newer versions of this gem might've already fixed this"
276
- raw_require_paths.flatten!
277
- end
286
+ if Gem.rubygems_version < Gem::Version.new("3.5.22")
287
+ module FixPathSourceMissingExtensions
288
+ def missing_extensions?
289
+ return false if %w[Bundler::Source::Path Bundler::Source::Gemspec].include?(source.class.name)
278
290
 
279
- class << self
280
- module RequirePathFlattener
281
- def from_yaml(input)
282
- spec = super(input)
283
- spec.flatten_require_paths
284
- spec
285
- end
291
+ super
286
292
  end
287
-
288
- prepend RequirePathFlattener
289
293
  end
294
+
295
+ prepend FixPathSourceMissingExtensions
290
296
  end
291
297
 
292
298
  private
@@ -397,6 +403,11 @@ module Gem
397
403
  @ignored = missing_extensions?
398
404
  end
399
405
  end
406
+
407
+ # Can be removed once RubyGems 3.6.9 support is dropped
408
+ unless new.respond_to?(:installable_on_platform?)
409
+ include(::Bundler::MatchPlatform)
410
+ end
400
411
  end
401
412
 
402
413
  require "rubygems/name_tuple"
@@ -443,6 +454,17 @@ module Gem
443
454
  end
444
455
  end
445
456
 
457
+ unless Gem.rubygems_version >= Gem::Version.new("3.6.7")
458
+ module UnfreezeCompactIndexParsedResponse
459
+ def parse(line)
460
+ version, platform, dependencies, requirements = super
461
+ [version, platform, dependencies.frozen? ? dependencies.dup : dependencies, requirements.frozen? ? requirements.dup : requirements]
462
+ end
463
+ end
464
+
465
+ Resolver::APISet::GemParser.prepend(UnfreezeCompactIndexParsedResponse)
466
+ end
467
+
446
468
  if Gem.rubygems_version < Gem::Version.new("3.6.0")
447
469
  class Package; end
448
470
  require "rubygems/package/tar_reader"
@@ -456,15 +478,4 @@ module Gem
456
478
 
457
479
  Package::TarReader::Entry.prepend(FixFullNameEncoding)
458
480
  end
459
-
460
- require "rubygems/uri"
461
-
462
- # Can be removed once RubyGems 3.3.15 support is dropped
463
- unless Gem::Uri.respond_to?(:redact)
464
- class Uri
465
- def self.redact(uri)
466
- new(uri).redacted
467
- end
468
- end
469
- end
470
481
  end
@@ -214,16 +214,11 @@ module Bundler
214
214
  e.requirement = dep.requirement
215
215
  raise e
216
216
  end
217
-
218
- # backwards compatibility shim, see https://github.com/rubygems/bundler/issues/5102
219
- kernel_class.send(:public, :gem) if Bundler.feature_flag.setup_makes_kernel_gem_public?
220
217
  end
221
218
  end
222
219
 
223
220
  # Used to give better error messages when activating specs outside of the current bundle
224
221
  def replace_bin_path(specs_by_name)
225
- gem_class = (class << Gem; self; end)
226
-
227
222
  redefine_method(gem_class, :find_spec_for_exe) do |gem_name, *args|
228
223
  exec_name = args.first
229
224
  raise ArgumentError, "you must supply exec_name" unless exec_name
@@ -345,9 +340,13 @@ module Bundler
345
340
  Gem::Specification.all = specs
346
341
  end
347
342
 
348
- redefine_method((class << Gem; self; end), :finish_resolve) do |*|
343
+ redefine_method(gem_class, :finish_resolve) do |*|
349
344
  []
350
345
  end
346
+
347
+ redefine_method(gem_class, :load_plugins) do |*|
348
+ load_plugin_files specs.flat_map(&:plugins)
349
+ end
351
350
  end
352
351
 
353
352
  def plain_specs
@@ -447,6 +446,12 @@ module Bundler
447
446
  def default_stubs
448
447
  Gem::Specification.default_stubs("*.gemspec")
449
448
  end
449
+
450
+ private
451
+
452
+ def gem_class
453
+ class << Gem; self; end
454
+ end
450
455
  end
451
456
 
452
457
  def self.rubygems
@@ -71,7 +71,7 @@ module Bundler
71
71
  raise Bundler::GemRequireError.new e,
72
72
  "There was an error while trying to load the gem '#{file}'."
73
73
  end
74
- rescue RuntimeError => e
74
+ rescue StandardError => e
75
75
  raise Bundler::GemRequireError.new e,
76
76
  "There was an error while trying to load the gem '#{file}'."
77
77
  end
@@ -130,11 +130,14 @@ module Bundler
130
130
 
131
131
  specs_to_cache.each do |spec|
132
132
  next if spec.name == "bundler"
133
- next if spec.source.is_a?(Source::Gemspec)
134
- if spec.source.respond_to?(:migrate_cache)
135
- spec.source.migrate_cache(custom_path, local: local)
136
- elsif spec.source.respond_to?(:cache)
137
- spec.source.cache(spec, custom_path)
133
+
134
+ source = spec.source
135
+ next if source.is_a?(Source::Gemspec)
136
+
137
+ if source.respond_to?(:migrate_cache)
138
+ source.migrate_cache(custom_path, local: local)
139
+ elsif source.respond_to?(:cache)
140
+ source.cache(spec, custom_path)
138
141
  end
139
142
  end
140
143
 
@@ -7,13 +7,15 @@ module Bundler
7
7
  #
8
8
  class SelfManager
9
9
  def restart_with_locked_bundler_if_needed
10
- return unless needs_switching? && installed?
10
+ restart_version = find_restart_version
11
+ return unless restart_version && installed?(restart_version)
11
12
 
12
13
  restart_with(restart_version)
13
14
  end
14
15
 
15
16
  def install_locked_bundler_and_restart_with_it_if_needed
16
- return unless needs_switching?
17
+ restart_version = find_restart_version
18
+ return unless restart_version
17
19
 
18
20
  if restart_version == lockfile_version
19
21
  Bundler.ui.info \
@@ -29,8 +31,6 @@ module Bundler
29
31
  end
30
32
 
31
33
  def update_bundler_and_restart_with_it_if_needed(target)
32
- return unless autoswitching_applies?
33
-
34
34
  spec = resolve_update_version_from(target)
35
35
  return unless spec
36
36
 
@@ -38,7 +38,7 @@ module Bundler
38
38
 
39
39
  Bundler.ui.info "Updating bundler to #{version}."
40
40
 
41
- install(spec)
41
+ install(spec) unless installed?(version)
42
42
 
43
43
  restart_with(version)
44
44
  end
@@ -68,47 +68,37 @@ module Bundler
68
68
 
69
69
  def restart_with(version)
70
70
  configured_gem_home = ENV["GEM_HOME"]
71
+ configured_orig_gem_home = ENV["BUNDLER_ORIG_GEM_HOME"]
71
72
  configured_gem_path = ENV["GEM_PATH"]
73
+ configured_orig_gem_path = ENV["BUNDLER_ORIG_GEM_PATH"]
72
74
 
73
- # Bundler specs need some stuff to be required before Bundler starts
74
- # running, for example, for faking the compact index API. However, these
75
- # flags are lost when we reexec to a different version of Bundler. In the
76
- # future, we may be able to properly reconstruct the original Ruby
77
- # invocation (see https://bugs.ruby-lang.org/issues/6648), but for now
78
- # there's no way to do it, so we need to be explicit about how to re-exec.
79
- # This may be a feature end users request at some point, but maybe by that
80
- # time, we have builtin tools to do. So for now, we use an undocumented
81
- # ENV variable only for our specs.
82
- bundler_spec_original_cmd = ENV["BUNDLER_SPEC_ORIGINAL_CMD"]
83
- if bundler_spec_original_cmd
84
- require "shellwords"
85
- cmd = [*Shellwords.shellsplit(bundler_spec_original_cmd), *ARGV]
86
- else
87
- argv0 = File.exist?($PROGRAM_NAME) ? $PROGRAM_NAME : Process.argv0
88
- cmd = [argv0, *ARGV]
89
- cmd.unshift(Gem.ruby) unless File.executable?(argv0)
90
- end
75
+ argv0 = File.exist?($PROGRAM_NAME) ? $PROGRAM_NAME : Process.argv0
76
+ cmd = [argv0, *ARGV]
77
+ cmd.unshift(Gem.ruby) unless File.executable?(argv0)
91
78
 
92
79
  Bundler.with_original_env do
93
80
  Kernel.exec(
94
- { "GEM_HOME" => configured_gem_home, "GEM_PATH" => configured_gem_path, "BUNDLER_VERSION" => version.to_s },
81
+ {
82
+ "GEM_HOME" => configured_gem_home,
83
+ "BUNDLER_ORIG_GEM_HOME" => configured_orig_gem_home,
84
+ "GEM_PATH" => configured_gem_path,
85
+ "BUNDLER_ORIG_GEM_PATH" => configured_orig_gem_path,
86
+ "BUNDLER_VERSION" => version.to_s,
87
+ },
95
88
  *cmd
96
89
  )
97
90
  end
98
91
  end
99
92
 
100
- def needs_switching?
93
+ def needs_switching?(restart_version)
101
94
  autoswitching_applies? &&
102
- Bundler.settings[:version] != "system" &&
103
95
  released?(restart_version) &&
104
- !running?(restart_version) &&
105
- !updating?
96
+ !running?(restart_version)
106
97
  end
107
98
 
108
99
  def autoswitching_applies?
109
100
  ENV["BUNDLER_VERSION"].nil? &&
110
101
  ruby_can_restart_with_same_arguments? &&
111
- SharedHelpers.in_bundle? &&
112
102
  lockfile_version
113
103
  end
114
104
 
@@ -142,6 +132,7 @@ module Bundler
142
132
  end
143
133
 
144
134
  def find_latest_matching_spec(requirement)
135
+ Bundler.configure
145
136
  local_result = find_latest_matching_spec_from_collection(local_specs, requirement)
146
137
  return local_result if local_result && requirement.specific?
147
138
 
@@ -171,18 +162,14 @@ module Bundler
171
162
  $PROGRAM_NAME != "-e"
172
163
  end
173
164
 
174
- def updating?
175
- "update".start_with?(ARGV.first || " ") && ARGV[1..-1].any? {|a| a.start_with?("--bundler") }
176
- end
177
-
178
- def installed?
165
+ def installed?(restart_version)
179
166
  Bundler.configure
180
167
 
181
168
  Bundler.rubygems.find_bundler(restart_version.to_s)
182
169
  end
183
170
 
184
171
  def current_version
185
- @current_version ||= Gem::Version.new(Bundler::VERSION)
172
+ @current_version ||= Bundler.gem_version
186
173
  end
187
174
 
188
175
  def lockfile_version
@@ -194,13 +181,16 @@ module Bundler
194
181
  @lockfile_version = nil
195
182
  end
196
183
 
197
- def restart_version
198
- return @restart_version if defined?(@restart_version)
199
- # BUNDLE_VERSION=x.y.z
200
- @restart_version = Gem::Version.new(Bundler.settings[:version])
201
- rescue ArgumentError
202
- # BUNDLE_VERSION=lockfile
203
- @restart_version = lockfile_version
184
+ def find_restart_version
185
+ return unless SharedHelpers.in_bundle?
186
+
187
+ configured_version = Bundler.settings[:version]
188
+ return if configured_version == "system"
189
+
190
+ restart_version = configured_version == "lockfile" ? lockfile_version : Gem::Version.new(configured_version)
191
+ return unless needs_switching?(restart_version)
192
+
193
+ restart_version
204
194
  end
205
195
  end
206
196
  end
@@ -74,29 +74,6 @@ module Bundler
74
74
  fail!(key, value, "`#{other_key}` is current set to #{other_setting.inspect}", "the `#{conflicting.join("`, `")}` groups conflict")
75
75
  end
76
76
  end
77
-
78
- rule %w[path], "relative paths are expanded relative to the current working directory" do |key, value, settings|
79
- next if value.nil?
80
-
81
- path = Pathname.new(value)
82
- next if !path.relative? || !Bundler.feature_flag.path_relative_to_cwd?
83
-
84
- path = path.expand_path
85
-
86
- root = begin
87
- Bundler.root
88
- rescue GemfileNotFound
89
- Pathname.pwd.expand_path
90
- end
91
-
92
- path = begin
93
- path.relative_path_from(root)
94
- rescue ArgumentError
95
- path
96
- end
97
-
98
- set(settings, key, path.to_s)
99
- end
100
77
  end
101
78
  end
102
79
  end
@@ -8,12 +8,10 @@ module Bundler
8
8
 
9
9
  BOOL_KEYS = %w[
10
10
  allow_offline_install
11
- auto_clean_without_path
12
11
  auto_install
13
12
  cache_all
14
13
  cache_all_platforms
15
14
  clean
16
- default_install_uses_path
17
15
  deployment
18
16
  disable_checksum_validation
19
17
  disable_exec_load
@@ -27,6 +25,7 @@ module Bundler
27
25
  gem.changelog
28
26
  gem.coc
29
27
  gem.mit
28
+ gem.bundle
30
29
  git.allow_insecure
31
30
  global_gem_cache
32
31
  ignore_messages
@@ -35,15 +34,13 @@ module Bundler
35
34
  lockfile_checksums
36
35
  no_install
37
36
  no_prune
38
- path_relative_to_cwd
39
37
  path.system
40
38
  plugins
41
39
  prefer_patch
42
- print_only_version_number
43
- setup_makes_kernel_gem_public
44
40
  silence_deprecations
45
41
  silence_root_warning
46
42
  update_requires_all_flag
43
+ verbose
47
44
  ].freeze
48
45
 
49
46
  REMEMBERED_KEYS = %w[
@@ -86,6 +83,7 @@ module Bundler
86
83
  gemfile
87
84
  path
88
85
  shebang
86
+ simulate_version
89
87
  system_bindir
90
88
  trust-policy
91
89
  version
@@ -274,7 +272,7 @@ module Bundler
274
272
  def use_system_gems?
275
273
  return true if system_path
276
274
  return false if explicit_path
277
- !Bundler.feature_flag.default_install_uses_path?
275
+ !Bundler.feature_flag.bundler_4_mode?
278
276
  end
279
277
 
280
278
  def base_path
@@ -115,6 +115,10 @@ module Bundler
115
115
  raise NoSpaceOnDeviceError.new(path, action)
116
116
  rescue Errno::ENOTSUP
117
117
  raise OperationNotSupportedError.new(path, action)
118
+ rescue Errno::EPERM
119
+ raise OperationNotPermittedError.new(path, action)
120
+ rescue Errno::EROFS
121
+ raise ReadOnlyFileSystemError.new(path, action)
118
122
  rescue Errno::EEXIST, Errno::ENOENT
119
123
  raise
120
124
  rescue SystemCallError => e
@@ -129,13 +133,16 @@ module Bundler
129
133
  removed_message += suffix if removed_message
130
134
  end
131
135
 
132
- bundler_major_version = Bundler.bundler_major_version
133
- if bundler_major_version > major_version
136
+ require_relative "../bundler"
137
+
138
+ feature_flag = Bundler.feature_flag
139
+
140
+ if feature_flag.removed_major?(major_version)
134
141
  require_relative "errors"
135
142
  raise DeprecatedError, "[REMOVED] #{removed_message || message}"
136
143
  end
137
144
 
138
- return unless bundler_major_version >= major_version && prints_major_deprecations?
145
+ return unless feature_flag.deprecated_major?(major_version) && prints_major_deprecations?
139
146
  Bundler.ui.warn("[DEPRECATED] #{message}")
140
147
  end
141
148
 
@@ -382,7 +389,6 @@ module Bundler
382
389
  end
383
390
 
384
391
  def prints_major_deprecations?
385
- require_relative "../bundler"
386
392
  return false if Bundler.settings[:silence_deprecations]
387
393
  require_relative "deprecate"
388
394
  return false if Bundler::Deprecate.skip