rubygems-update 3.6.2 → 3.6.4

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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/bundler/CHANGELOG.md +53 -0
  4. data/bundler/README.md +2 -2
  5. data/bundler/lib/bundler/build_metadata.rb +2 -2
  6. data/bundler/lib/bundler/cli/console.rb +8 -6
  7. data/bundler/lib/bundler/cli/doctor.rb +9 -5
  8. data/bundler/lib/bundler/cli/info.rb +4 -4
  9. data/bundler/lib/bundler/cli/issue.rb +1 -1
  10. data/bundler/lib/bundler/cli/outdated.rb +6 -4
  11. data/bundler/lib/bundler/cli/show.rb +1 -1
  12. data/bundler/lib/bundler/current_ruby.rb +23 -33
  13. data/bundler/lib/bundler/definition.rb +62 -60
  14. data/bundler/lib/bundler/dependency.rb +92 -47
  15. data/bundler/lib/bundler/dsl.rb +83 -78
  16. data/bundler/lib/bundler/endpoint_specification.rb +10 -3
  17. data/bundler/lib/bundler/errors.rb +4 -0
  18. data/bundler/lib/bundler/feature_flag.rb +2 -6
  19. data/bundler/lib/bundler/gem_helpers.rb +4 -10
  20. data/bundler/lib/bundler/gem_version_promoter.rb +0 -2
  21. data/bundler/lib/bundler/installer.rb +16 -2
  22. data/bundler/lib/bundler/lazy_specification.rb +50 -45
  23. data/bundler/lib/bundler/man/bundle-add.1 +3 -3
  24. data/bundler/lib/bundler/man/bundle-binstubs.1 +3 -3
  25. data/bundler/lib/bundler/man/bundle-cache.1 +3 -3
  26. data/bundler/lib/bundler/man/bundle-check.1 +3 -3
  27. data/bundler/lib/bundler/man/bundle-clean.1 +3 -3
  28. data/bundler/lib/bundler/man/bundle-config.1 +3 -3
  29. data/bundler/lib/bundler/man/bundle-console.1 +3 -3
  30. data/bundler/lib/bundler/man/bundle-doctor.1 +3 -3
  31. data/bundler/lib/bundler/man/bundle-env.1 +3 -3
  32. data/bundler/lib/bundler/man/bundle-exec.1 +3 -3
  33. data/bundler/lib/bundler/man/bundle-fund.1 +3 -3
  34. data/bundler/lib/bundler/man/bundle-gem.1 +3 -3
  35. data/bundler/lib/bundler/man/bundle-help.1 +3 -3
  36. data/bundler/lib/bundler/man/bundle-info.1 +3 -3
  37. data/bundler/lib/bundler/man/bundle-init.1 +3 -3
  38. data/bundler/lib/bundler/man/bundle-inject.1 +3 -3
  39. data/bundler/lib/bundler/man/bundle-install.1 +3 -3
  40. data/bundler/lib/bundler/man/bundle-issue.1 +3 -3
  41. data/bundler/lib/bundler/man/bundle-licenses.1 +3 -3
  42. data/bundler/lib/bundler/man/bundle-list.1 +3 -3
  43. data/bundler/lib/bundler/man/bundle-lock.1 +3 -3
  44. data/bundler/lib/bundler/man/bundle-open.1 +3 -3
  45. data/bundler/lib/bundler/man/bundle-outdated.1 +3 -3
  46. data/bundler/lib/bundler/man/bundle-platform.1 +3 -3
  47. data/bundler/lib/bundler/man/bundle-plugin.1 +3 -3
  48. data/bundler/lib/bundler/man/bundle-pristine.1 +3 -3
  49. data/bundler/lib/bundler/man/bundle-remove.1 +3 -3
  50. data/bundler/lib/bundler/man/bundle-show.1 +3 -3
  51. data/bundler/lib/bundler/man/bundle-update.1 +3 -3
  52. data/bundler/lib/bundler/man/bundle-version.1 +3 -3
  53. data/bundler/lib/bundler/man/bundle-viz.1 +3 -3
  54. data/bundler/lib/bundler/man/bundle.1 +3 -3
  55. data/bundler/lib/bundler/man/gemfile.5 +3 -3
  56. data/bundler/lib/bundler/match_metadata.rb +13 -0
  57. data/bundler/lib/bundler/plugin/index.rb +4 -0
  58. data/bundler/lib/bundler/resolver/base.rb +2 -1
  59. data/bundler/lib/bundler/resolver/package.rb +8 -4
  60. data/bundler/lib/bundler/resolver/spec_group.rb +1 -25
  61. data/bundler/lib/bundler/resolver.rb +13 -3
  62. data/bundler/lib/bundler/ruby_dsl.rb +12 -3
  63. data/bundler/lib/bundler/rubygems_ext.rb +83 -82
  64. data/bundler/lib/bundler/rubygems_integration.rb +2 -15
  65. data/bundler/lib/bundler/runtime.rb +19 -24
  66. data/bundler/lib/bundler/source/git.rb +1 -0
  67. data/bundler/lib/bundler/source/rubygems.rb +19 -4
  68. data/bundler/lib/bundler/source.rb +2 -0
  69. data/bundler/lib/bundler/source_list.rb +4 -0
  70. data/bundler/lib/bundler/spec_set.rb +66 -29
  71. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +1 -0
  72. data/bundler/lib/bundler/version.rb +1 -1
  73. data/bundler/lib/bundler.rb +10 -30
  74. data/doc/rubygems/POLICIES.md +1 -1
  75. data/lib/rubygems/commands/environment_command.rb +5 -0
  76. data/lib/rubygems/requirement.rb +5 -3
  77. data/lib/rubygems/specification.rb +5 -7
  78. data/lib/rubygems/util/licenses.rb +19 -0
  79. data/lib/rubygems.rb +9 -2
  80. data/rubygems-update.gemspec +1 -1
  81. metadata +3 -3
@@ -58,6 +58,87 @@ module Gem
58
58
  end
59
59
  end
60
60
 
61
+ require "rubygems/platform"
62
+
63
+ 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
99
+
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
104
+
105
+ without_gnu_nor_abi_modifiers = @version.sub(/\Agnu/, "").sub(/eabi(hf)?\Z/, "")
106
+ return nil if without_gnu_nor_abi_modifiers.empty?
107
+
108
+ without_gnu_nor_abi_modifiers
109
+ end
110
+ end
111
+ end
112
+
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
118
+
119
+ def match_gem?(platform, gem_name)
120
+ match_platforms?(platform, Gem.platforms)
121
+ end
122
+ end
123
+
124
+ match_platforms_defined = Gem::Platform.respond_to?(:match_platforms?, true)
125
+
126
+ if !match_platforms_defined || Gem::Platform.send(:match_platforms?, Gem::Platform::X64_LINUX_MUSL, [Gem::Platform::X64_LINUX])
127
+
128
+ private
129
+
130
+ remove_method :match_platforms? if match_platforms_defined
131
+
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)
137
+ end
138
+ end
139
+ end
140
+ end
141
+
61
142
  require "rubygems/specification"
62
143
 
63
144
  # Can be removed once RubyGems 3.5.14 support is dropped
@@ -177,8 +258,8 @@ module Gem
177
258
  dependencies - development_dependencies
178
259
  end
179
260
 
180
- def deleted_gem?
181
- !default_gem? && !File.directory?(full_gem_path)
261
+ def installation_missing?
262
+ !default_gem? && (!Dir.exist?(full_gem_path) || Dir.empty?(full_gem_path))
182
263
  end
183
264
 
184
265
  unless VALIDATES_FOR_RESOLUTION
@@ -288,86 +369,6 @@ module Gem
288
369
  end
289
370
  end
290
371
 
291
- require "rubygems/platform"
292
-
293
- class Platform
294
- JAVA = Gem::Platform.new("java")
295
- MSWIN = Gem::Platform.new("mswin32")
296
- MSWIN64 = Gem::Platform.new("mswin64")
297
- MINGW = Gem::Platform.new("x86-mingw32")
298
- X64_MINGW = [Gem::Platform.new("x64-mingw32"),
299
- Gem::Platform.new("x64-mingw-ucrt")].freeze
300
- WINDOWS = [MSWIN, MSWIN64, MINGW, X64_MINGW].flatten.freeze
301
- X64_LINUX = Gem::Platform.new("x86_64-linux")
302
- X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl")
303
-
304
- if X64_LINUX === X64_LINUX_MUSL
305
- remove_method :===
306
-
307
- def ===(other)
308
- return nil unless Gem::Platform === other
309
-
310
- # universal-mingw32 matches x64-mingw-ucrt
311
- return true if (@cpu == "universal" || other.cpu == "universal") &&
312
- @os.start_with?("mingw") && other.os.start_with?("mingw")
313
-
314
- # cpu
315
- ([nil,"universal"].include?(@cpu) || [nil, "universal"].include?(other.cpu) || @cpu == other.cpu ||
316
- (@cpu == "arm" && other.cpu.start_with?("armv"))) &&
317
-
318
- # os
319
- @os == other.os &&
320
-
321
- # version
322
- (
323
- (@os != "linux" && (@version.nil? || other.version.nil?)) ||
324
- (@os == "linux" && (normalized_linux_version_ext == other.normalized_linux_version_ext || ["musl#{@version}", "musleabi#{@version}", "musleabihf#{@version}"].include?(other.version))) ||
325
- @version == other.version
326
- )
327
- end
328
-
329
- # This is a copy of RubyGems 3.3.23 or higher `normalized_linux_method`.
330
- # Once only 3.3.23 is supported, we can use the method in RubyGems.
331
- def normalized_linux_version_ext
332
- return nil unless @version
333
-
334
- without_gnu_nor_abi_modifiers = @version.sub(/\Agnu/, "").sub(/eabi(hf)?\Z/, "")
335
- return nil if without_gnu_nor_abi_modifiers.empty?
336
-
337
- without_gnu_nor_abi_modifiers
338
- end
339
- end
340
- end
341
-
342
- Platform.singleton_class.module_eval do
343
- unless Platform.singleton_methods.include?(:match_spec?)
344
- def match_spec?(spec)
345
- match_gem?(spec.platform, spec.name)
346
- end
347
-
348
- def match_gem?(platform, gem_name)
349
- match_platforms?(platform, Gem.platforms)
350
- end
351
- end
352
-
353
- match_platforms_defined = Gem::Platform.respond_to?(:match_platforms?, true)
354
-
355
- if !match_platforms_defined || Gem::Platform.send(:match_platforms?, Gem::Platform::X64_LINUX_MUSL, [Gem::Platform::X64_LINUX])
356
-
357
- private
358
-
359
- remove_method :match_platforms? if match_platforms_defined
360
-
361
- def match_platforms?(platform, platforms)
362
- platforms.any? do |local_platform|
363
- platform.nil? ||
364
- local_platform == platform ||
365
- (local_platform != Gem::Platform::RUBY && platform =~ local_platform)
366
- end
367
- end
368
- end
369
- end
370
-
371
372
  # On universal Rubies, resolve the "universal" arch to the real CPU arch, without changing the extension directory.
372
373
  class BasicSpecification
373
374
  if /^universal\.(?<arch>.*?)-/ =~ (CROSS_COMPILING || RUBY_PLATFORM)
@@ -134,18 +134,6 @@ module Bundler
134
134
  loaded_gem_paths.flatten
135
135
  end
136
136
 
137
- def load_plugins
138
- Gem.load_plugins
139
- end
140
-
141
- def load_plugin_files(plugin_files)
142
- Gem.load_plugin_files(plugin_files)
143
- end
144
-
145
- def load_env_plugins
146
- Gem.load_env_plugins
147
- end
148
-
149
137
  def ui=(obj)
150
138
  Gem::DefaultUserInteraction.ui = obj
151
139
  end
@@ -189,7 +177,7 @@ module Bundler
189
177
  end
190
178
  end
191
179
 
192
- def replace_gem(specs, specs_by_name)
180
+ def replace_gem(specs_by_name)
193
181
  executables = nil
194
182
 
195
183
  [::Kernel.singleton_class, ::Kernel].each do |kernel_class|
@@ -286,7 +274,7 @@ module Bundler
286
274
  else
287
275
  Gem::BUNDLED_GEMS.replace_require(specs) if Gem::BUNDLED_GEMS.respond_to?(:replace_require)
288
276
  end
289
- replace_gem(specs, specs_by_name)
277
+ replace_gem(specs_by_name)
290
278
  stub_rubygems(specs_by_name.values)
291
279
  replace_bin_path(specs_by_name)
292
280
 
@@ -305,7 +293,6 @@ module Bundler
305
293
  default_spec_name = default_spec.name
306
294
  next if specs_by_name.key?(default_spec_name)
307
295
 
308
- specs << default_spec
309
296
  specs_by_name[default_spec_name] = default_spec
310
297
  end
311
298
 
@@ -50,35 +50,30 @@ module Bundler
50
50
  Plugin.hook(Plugin::Events::GEM_BEFORE_REQUIRE_ALL, dependencies)
51
51
 
52
52
  dependencies.each do |dep|
53
- required_file = nil
54
53
  Plugin.hook(Plugin::Events::GEM_BEFORE_REQUIRE, dep)
55
54
 
56
- begin
57
- # Loop through all the specified autorequires for the
58
- # dependency. If there are none, use the dependency's name
59
- # as the autorequire.
60
- Array(dep.autorequire || dep.name).each do |file|
61
- # Allow `require: true` as an alias for `require: <name>`
62
- file = dep.name if file == true
63
- required_file = file
64
- begin
65
- Kernel.require file
66
- rescue RuntimeError => e
67
- raise e if e.is_a?(LoadError) # we handle this a little later
55
+ # Loop through all the specified autorequires for the
56
+ # dependency. If there are none, use the dependency's name
57
+ # as the autorequire.
58
+ Array(dep.autorequire || dep.name).each do |file|
59
+ # Allow `require: true` as an alias for `require: <name>`
60
+ file = dep.name if file == true
61
+ required_file = file
62
+ begin
63
+ Kernel.require required_file
64
+ rescue LoadError => e
65
+ if dep.autorequire.nil? && e.path == required_file
66
+ if required_file.include?("-")
67
+ required_file = required_file.tr("-", "/")
68
+ retry
69
+ end
70
+ else
68
71
  raise Bundler::GemRequireError.new e,
69
72
  "There was an error while trying to load the gem '#{file}'."
70
73
  end
71
- end
72
- rescue LoadError => e
73
- raise if dep.autorequire || e.path != required_file
74
-
75
- if dep.autorequire.nil? && dep.name.include?("-")
76
- begin
77
- namespaced_file = dep.name.tr("-", "/")
78
- Kernel.require namespaced_file
79
- rescue LoadError => e
80
- raise if e.path != namespaced_file
81
- end
74
+ rescue RuntimeError => e
75
+ raise Bundler::GemRequireError.new e,
76
+ "There was an error while trying to load the gem '#{file}'."
82
77
  end
83
78
  end
84
79
 
@@ -282,6 +282,7 @@ module Bundler
282
282
  FileUtils.rm_rf(app_cache_path)
283
283
  git_proxy.checkout if migrate || requires_checkout?
284
284
  git_proxy.copy_to(app_cache_path, @submodules)
285
+ serialize_gemspecs_in(app_cache_path)
285
286
  end
286
287
 
287
288
  def checkout
@@ -19,6 +19,7 @@ module Bundler
19
19
  @allow_remote = false
20
20
  @allow_cached = false
21
21
  @allow_local = options["allow_local"] || false
22
+ @prefer_local = false
22
23
  @checksum_store = Checksum::Store.new
23
24
 
24
25
  Array(options["remotes"]).reverse_each {|r| add_remote(r) }
@@ -30,6 +31,10 @@ module Bundler
30
31
  @caches ||= [cache_path, *Bundler.rubygems.gem_cache]
31
32
  end
32
33
 
34
+ def prefer_local!
35
+ @prefer_local = true
36
+ end
37
+
33
38
  def local_only!
34
39
  @specs = nil
35
40
  @allow_local = true
@@ -37,6 +42,10 @@ module Bundler
37
42
  @allow_remote = false
38
43
  end
39
44
 
45
+ def local_only?
46
+ @allow_local && !@allow_remote
47
+ end
48
+
40
49
  def local!
41
50
  return if @allow_local
42
51
 
@@ -139,9 +148,15 @@ module Bundler
139
148
  index.merge!(cached_specs) if @allow_cached
140
149
  index.merge!(installed_specs) if @allow_local
141
150
 
142
- # complete with default specs, only if not already available in the
143
- # index through remote, cached, or installed specs
144
- index.use(default_specs) if @allow_local
151
+ if @allow_local
152
+ if @prefer_local
153
+ index.merge!(default_specs)
154
+ else
155
+ # complete with default specs, only if not already available in the
156
+ # index through remote, cached, or installed specs
157
+ index.use(default_specs)
158
+ end
159
+ end
145
160
 
146
161
  index
147
162
  end
@@ -439,7 +454,7 @@ module Bundler
439
454
  end
440
455
 
441
456
  def installed?(spec)
442
- installed_specs[spec].any? && !spec.deleted_gem?
457
+ installed_specs[spec].any? && !spec.installation_missing?
443
458
  end
444
459
 
445
460
  def rubygems_dir
@@ -35,6 +35,8 @@ module Bundler
35
35
  spec.source == self
36
36
  end
37
37
 
38
+ def prefer_local!; end
39
+
38
40
  def local!; end
39
41
 
40
42
  def local_only!; end
@@ -141,6 +141,10 @@ module Bundler
141
141
  different_sources?(lock_sources, replacement_sources)
142
142
  end
143
143
 
144
+ def prefer_local!
145
+ all_sources.each(&:prefer_local!)
146
+ end
147
+
144
148
  def local_only!
145
149
  all_sources.each(&:local_only!)
146
150
  end
@@ -83,15 +83,13 @@ module Bundler
83
83
  end
84
84
 
85
85
  def []=(key, value)
86
- @specs << value
86
+ delete_by_name(key)
87
87
 
88
- reset!
88
+ add_spec(value)
89
89
  end
90
90
 
91
91
  def delete(specs)
92
- Array(specs).each {|spec| @specs.delete(spec) }
93
-
94
- reset!
92
+ Array(specs).each {|spec| remove_spec(spec) }
95
93
  end
96
94
 
97
95
  def sort!
@@ -117,8 +115,7 @@ module Bundler
117
115
  def materialized_for_all_platforms
118
116
  @specs.map do |s|
119
117
  next s unless s.is_a?(LazySpecification)
120
- s.source.remote!
121
- spec = s.materialize_strictly
118
+ spec = s.materialize_for_cache
122
119
  raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
123
120
  spec
124
121
  end
@@ -133,8 +130,8 @@ module Bundler
133
130
  validation_set.incomplete_specs.any?
134
131
  end
135
132
 
136
- def missing_specs_for(dependencies)
137
- materialize_dependencies(dependencies)
133
+ def missing_specs_for(deps)
134
+ materialize_dependencies(deps)
138
135
 
139
136
  missing_specs
140
137
  end
@@ -163,10 +160,20 @@ module Bundler
163
160
  @specs.detect {|spec| spec.name == name && spec.match_platform(platform) }
164
161
  end
165
162
 
163
+ def specs_with_additional_variants_from(other)
164
+ sorted | additional_variants_from(other)
165
+ end
166
+
166
167
  def delete_by_name(name)
167
168
  @specs.reject! {|spec| spec.name == name }
169
+ @sorted&.reject! {|spec| spec.name == name }
170
+ return if @lookup.nil?
168
171
 
169
- reset!
172
+ @lookup[name] = nil
173
+ end
174
+
175
+ def version_for(name)
176
+ self[name].first&.version
170
177
  end
171
178
 
172
179
  def what_required(spec)
@@ -204,6 +211,10 @@ module Bundler
204
211
  s.matches_current_metadata? && valid_dependencies?(s)
205
212
  end
206
213
 
214
+ def to_s
215
+ map(&:full_name).to_s
216
+ end
217
+
207
218
  private
208
219
 
209
220
  def materialize_dependencies(dependencies, platforms = [nil], skips: [])
@@ -237,11 +248,6 @@ module Bundler
237
248
  @materializations.filter_map(&:materialized_spec)
238
249
  end
239
250
 
240
- def reset!
241
- @sorted = nil
242
- @lookup = nil
243
- end
244
-
245
251
  def complete_platform(platform)
246
252
  new_specs = []
247
253
 
@@ -261,9 +267,7 @@ module Bundler
261
267
  end
262
268
 
263
269
  if valid_platform && new_specs.any?
264
- @specs.concat(new_specs)
265
-
266
- reset!
270
+ new_specs.each {|spec| add_spec(spec) }
267
271
  end
268
272
 
269
273
  valid_platform
@@ -273,20 +277,23 @@ module Bundler
273
277
  @specs.flat_map {|spec| spec.source.specs.search([spec.name, spec.version]).map(&:platform) }.uniq
274
278
  end
275
279
 
280
+ def additional_variants_from(other)
281
+ other.select do |spec|
282
+ version_for(spec.name) == spec.version && valid_dependencies?(spec)
283
+ end
284
+ end
285
+
276
286
  def valid_dependencies?(s)
277
287
  validate_deps(s) == :valid
278
288
  end
279
289
 
280
290
  def sorted
281
- rake = @specs.find {|s| s.name == "rake" }
282
- begin
283
- @sorted ||= ([rake] + tsort).compact.uniq
284
- rescue TSort::Cyclic => error
285
- cgems = extract_circular_gems(error)
286
- raise CyclicDependencyError, "Your bundle requires gems that depend" \
287
- " on each other, creating an infinite loop. Please remove either" \
288
- " gem '#{cgems[0]}' or gem '#{cgems[1]}' and try again."
289
- end
291
+ @sorted ||= ([@specs.find {|s| s.name == "rake" }] + tsort).compact.uniq
292
+ rescue TSort::Cyclic => error
293
+ cgems = extract_circular_gems(error)
294
+ raise CyclicDependencyError, "Your bundle requires gems that depend" \
295
+ " on each other, creating an infinite loop. Please remove either" \
296
+ " gem '#{cgems[0]}' or gem '#{cgems[1]}' and try again."
290
297
  end
291
298
 
292
299
  def extract_circular_gems(error)
@@ -297,8 +304,7 @@ module Bundler
297
304
  @lookup ||= begin
298
305
  lookup = {}
299
306
  @specs.each do |s|
300
- lookup[s.name] ||= []
301
- lookup[s.name] << s
307
+ index_spec(lookup, s.name, s)
302
308
  end
303
309
  lookup
304
310
  end
@@ -319,5 +325,36 @@ module Bundler
319
325
  specs_for_name.each {|s2| yield s2 }
320
326
  end
321
327
  end
328
+
329
+ def add_spec(spec)
330
+ @specs << spec
331
+
332
+ name = spec.name
333
+
334
+ @sorted&.insert(@sorted.bsearch_index {|s| s.name >= name } || @sorted.size, spec)
335
+ return if @lookup.nil?
336
+
337
+ index_spec(@lookup, name, spec)
338
+ end
339
+
340
+ def remove_spec(spec)
341
+ @specs.delete(spec)
342
+ @sorted&.delete(spec)
343
+ return if @lookup.nil?
344
+
345
+ indexed_specs = @lookup[spec.name]
346
+ return unless indexed_specs
347
+
348
+ if indexed_specs.size > 1
349
+ @lookup[spec.name].delete(spec)
350
+ else
351
+ @lookup[spec.name] = nil
352
+ end
353
+ end
354
+
355
+ def index_spec(hash, key, value)
356
+ hash[key] ||= []
357
+ hash[key] << value
358
+ end
322
359
  end
323
360
  end
@@ -5,6 +5,7 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in <%= config[:name] %>.gemspec
6
6
  gemspec
7
7
 
8
+ gem "irb"
8
9
  gem "rake", "~> 13.0"
9
10
  <%- if config[:ext] -%>
10
11
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "2.6.2".freeze
4
+ VERSION = "2.6.4".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= VERSION.split(".").first.to_i
@@ -212,7 +212,6 @@ module Bundler
212
212
  # Bundler.require(:test) # requires second_gem
213
213
  #
214
214
  def require(*groups)
215
- load_plugins
216
215
  setup(*groups).require(*groups)
217
216
  end
218
217
 
@@ -548,15 +547,7 @@ module Bundler
548
547
  def load_gemspec_uncached(file, validate = false)
549
548
  path = Pathname.new(file)
550
549
  contents = read_file(file)
551
- spec = if contents.start_with?("---") # YAML header
552
- eval_yaml_gemspec(path, contents)
553
- else
554
- # Eval the gemspec from its parent directory, because some gemspecs
555
- # depend on "./" relative paths.
556
- SharedHelpers.chdir(path.dirname.to_s) do
557
- eval_gemspec(path, contents)
558
- end
559
- end
550
+ spec = eval_gemspec(path, contents)
560
551
  return unless spec
561
552
  spec.loaded_from = path.expand_path.to_s
562
553
  Bundler.rubygems.validate(spec) if validate
@@ -576,23 +567,6 @@ module Bundler
576
567
  @feature_flag ||= FeatureFlag.new(VERSION)
577
568
  end
578
569
 
579
- def load_plugins(definition = Bundler.definition)
580
- return if defined?(@load_plugins_ran)
581
-
582
- Bundler.rubygems.load_plugins
583
-
584
- requested_path_gems = definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
585
- path_plugin_files = requested_path_gems.flat_map do |spec|
586
- spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
587
- rescue TypeError
588
- error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
589
- raise Gem::InvalidSpecificationException, error_message
590
- end
591
- Bundler.rubygems.load_plugin_files(path_plugin_files)
592
- Bundler.rubygems.load_env_plugins
593
- @load_plugins_ran = true
594
- end
595
-
596
570
  def reset!
597
571
  reset_paths!
598
572
  Plugin.reset!
@@ -675,12 +649,18 @@ module Bundler
675
649
  Kernel.require "psych"
676
650
 
677
651
  Gem::Specification.from_yaml(contents)
678
- rescue ::Psych::SyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception
679
- eval_gemspec(path, contents)
680
652
  end
681
653
 
682
654
  def eval_gemspec(path, contents)
683
- eval(contents, TOPLEVEL_BINDING.dup, path.expand_path.to_s)
655
+ if contents.start_with?("---") # YAML header
656
+ eval_yaml_gemspec(path, contents)
657
+ else
658
+ # Eval the gemspec from its parent directory, because some gemspecs
659
+ # depend on "./" relative paths.
660
+ SharedHelpers.chdir(path.dirname.to_s) do
661
+ eval(contents, TOPLEVEL_BINDING.dup, path.expand_path.to_s)
662
+ end
663
+ end
684
664
  rescue ScriptError, StandardError => e
685
665
  msg = "There was an error while loading `#{path.basename}`: #{e.message}"
686
666
 
@@ -95,7 +95,7 @@ the version in all version files, synchronizes both changelogs to include all
95
95
  backported changes and commits that change on top of the cherry-picks.
96
96
 
97
97
  Note that this task requires all user facing pull requests to be tagged with
98
- specific labels. See [Merging a PR](/bundler/doc/playbooks/MERGING_A_PR.md) for details.
98
+ specific labels. See [Merging a PR](../bundler/playbooks/MERGING_A_PR.md) for details.
99
99
 
100
100
  Also note that when this task cherry-picks, it cherry-picks the merge commits
101
101
  using the following command:
@@ -15,6 +15,7 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
15
15
  version display the gem format version
16
16
  remotesources display the remote gem servers
17
17
  platform display the supported gem platforms
18
+ credentials display the path where credentials are stored
18
19
  <omitted> display everything
19
20
  EOF
20
21
  args.gsub(/^\s+/, "")
@@ -88,6 +89,8 @@ lib/rubygems/defaults/operating_system.rb
88
89
  Gem.sources.to_a.join("\n")
89
90
  when /^platform/ then
90
91
  Gem.platforms.join(File::PATH_SEPARATOR)
92
+ when /^credentials/, /^creds/ then
93
+ Gem.configuration.credentials_path
91
94
  when nil then
92
95
  show_environment
93
96
  else
@@ -114,6 +117,8 @@ lib/rubygems/defaults/operating_system.rb
114
117
 
115
118
  out << " - USER INSTALLATION DIRECTORY: #{Gem.user_dir}\n"
116
119
 
120
+ out << " - CREDENTIALS FILE: #{Gem.configuration.credentials_path}\n"
121
+
117
122
  out << " - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil?
118
123
 
119
124
  out << " - RUBY EXECUTABLE: #{Gem.ruby}\n"