bundler 2.6.3 → 2.6.5

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.
@@ -39,9 +39,7 @@ module Bundler
39
39
  end
40
40
 
41
41
  def dependencies
42
- @dependencies ||= @specs.flat_map do |spec|
43
- __dependencies(spec) + metadata_dependencies(spec)
44
- end.uniq.sort
42
+ @dependencies ||= @specs.flat_map(&:expanded_dependencies).uniq.sort
45
43
  end
46
44
 
47
45
  def ==(other)
@@ -71,28 +69,6 @@ module Bundler
71
69
  def exemplary_spec
72
70
  @specs.first
73
71
  end
74
-
75
- def __dependencies(spec)
76
- dependencies = []
77
- spec.dependencies.each do |dep|
78
- next if dep.type == :development
79
- dependencies << Dependency.new(dep.name, dep.requirement)
80
- end
81
- dependencies
82
- end
83
-
84
- def metadata_dependencies(spec)
85
- [
86
- metadata_dependency("Ruby", spec.required_ruby_version),
87
- metadata_dependency("RubyGems", spec.required_rubygems_version),
88
- ].compact
89
- end
90
-
91
- def metadata_dependency(name, requirement)
92
- return if requirement.nil? || requirement.none?
93
-
94
- Dependency.new("#{name}\0", requirement)
95
- end
96
72
  end
97
73
  end
98
74
  end
@@ -237,7 +237,7 @@ module Bundler
237
237
  sorted_versions[high]
238
238
  end
239
239
 
240
- range = PubGrub::VersionRange.new(min: low, max: high, include_min: true)
240
+ range = PubGrub::VersionRange.new(min: low, max: high, include_min: !low.nil?)
241
241
 
242
242
  self_constraint = PubGrub::VersionConstraint.new(package, range: range)
243
243
 
@@ -389,9 +389,18 @@ module Bundler
389
389
  end
390
390
 
391
391
  def filter_remote_specs(specs, package)
392
- return specs unless package.prefer_local?
392
+ if package.prefer_local?
393
+ local_specs = specs.select {|s| s.is_a?(StubSpecification) }
393
394
 
394
- specs.select {|s| s.is_a?(StubSpecification) }
395
+ if local_specs.empty?
396
+ package.consider_remote_versions!
397
+ specs
398
+ else
399
+ local_specs
400
+ end
401
+ else
402
+ specs
403
+ end
395
404
  end
396
405
 
397
406
  # Ignore versions that depend on themselves incorrectly
@@ -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,7 +258,7 @@ module Gem
177
258
  dependencies - development_dependencies
178
259
  end
179
260
 
180
- def deleted_gem?
261
+ def installation_missing?
181
262
  !default_gem? && !File.directory?(full_gem_path)
182
263
  end
183
264
 
@@ -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)
@@ -177,7 +177,7 @@ module Bundler
177
177
  end
178
178
  end
179
179
 
180
- def replace_gem(specs, specs_by_name)
180
+ def replace_gem(specs_by_name)
181
181
  executables = nil
182
182
 
183
183
  [::Kernel.singleton_class, ::Kernel].each do |kernel_class|
@@ -274,7 +274,7 @@ module Bundler
274
274
  else
275
275
  Gem::BUNDLED_GEMS.replace_require(specs) if Gem::BUNDLED_GEMS.respond_to?(:replace_require)
276
276
  end
277
- replace_gem(specs, specs_by_name)
277
+ replace_gem(specs_by_name)
278
278
  stub_rubygems(specs_by_name.values)
279
279
  replace_bin_path(specs_by_name)
280
280
 
@@ -293,7 +293,6 @@ module Bundler
293
293
  default_spec_name = default_spec.name
294
294
  next if specs_by_name.key?(default_spec_name)
295
295
 
296
- specs << default_spec
297
296
  specs_by_name[default_spec_name] = default_spec
298
297
  end
299
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
 
@@ -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
@@ -169,8 +166,10 @@ module Bundler
169
166
 
170
167
  def delete_by_name(name)
171
168
  @specs.reject! {|spec| spec.name == name }
169
+ @sorted&.reject! {|spec| spec.name == name }
170
+ return if @lookup.nil?
172
171
 
173
- reset!
172
+ @lookup[name] = nil
174
173
  end
175
174
 
176
175
  def version_for(name)
@@ -212,6 +211,10 @@ module Bundler
212
211
  s.matches_current_metadata? && valid_dependencies?(s)
213
212
  end
214
213
 
214
+ def to_s
215
+ map(&:full_name).to_s
216
+ end
217
+
215
218
  private
216
219
 
217
220
  def materialize_dependencies(dependencies, platforms = [nil], skips: [])
@@ -245,11 +248,6 @@ module Bundler
245
248
  @materializations.filter_map(&:materialized_spec)
246
249
  end
247
250
 
248
- def reset!
249
- @sorted = nil
250
- @lookup = nil
251
- end
252
-
253
251
  def complete_platform(platform)
254
252
  new_specs = []
255
253
 
@@ -269,9 +267,7 @@ module Bundler
269
267
  end
270
268
 
271
269
  if valid_platform && new_specs.any?
272
- @specs.concat(new_specs)
273
-
274
- reset!
270
+ new_specs.each {|spec| add_spec(spec) }
275
271
  end
276
272
 
277
273
  valid_platform
@@ -292,15 +288,12 @@ module Bundler
292
288
  end
293
289
 
294
290
  def sorted
295
- rake = @specs.find {|s| s.name == "rake" }
296
- begin
297
- @sorted ||= ([rake] + tsort).compact.uniq
298
- rescue TSort::Cyclic => error
299
- cgems = extract_circular_gems(error)
300
- raise CyclicDependencyError, "Your bundle requires gems that depend" \
301
- " on each other, creating an infinite loop. Please remove either" \
302
- " gem '#{cgems[0]}' or gem '#{cgems[1]}' and try again."
303
- 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."
304
297
  end
305
298
 
306
299
  def extract_circular_gems(error)
@@ -311,8 +304,7 @@ module Bundler
311
304
  @lookup ||= begin
312
305
  lookup = {}
313
306
  @specs.each do |s|
314
- lookup[s.name] ||= []
315
- lookup[s.name] << s
307
+ index_spec(lookup, s.name, s)
316
308
  end
317
309
  lookup
318
310
  end
@@ -333,5 +325,36 @@ module Bundler
333
325
  specs_for_name.each {|s2| yield s2 }
334
326
  end
335
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
336
359
  end
337
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.3".freeze
4
+ VERSION = "2.6.5".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= VERSION.split(".").first.to_i
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.3
4
+ version: 2.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Arko
@@ -21,7 +21,7 @@ authors:
21
21
  - Yehuda Katz
22
22
  bindir: exe
23
23
  cert_chain: []
24
- date: 2025-01-16 00:00:00.000000000 Z
24
+ date: 2025-02-20 00:00:00.000000000 Z
25
25
  dependencies: []
26
26
  description: Bundler manages an application's dependencies through its entire life,
27
27
  across many machines, systematically and repeatably
@@ -411,7 +411,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
411
411
  - !ruby/object:Gem::Version
412
412
  version: 3.3.3
413
413
  requirements: []
414
- rubygems_version: 3.6.3
414
+ rubygems_version: 3.6.5
415
415
  specification_version: 4
416
416
  summary: The best way to manage your application's dependencies
417
417
  test_files: []