bundler 4.1.0 → 4.1.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.
- checksums.yaml +4 -4
- data/bundler.gemspec +5 -3
- data/lib/bundler/build_metadata.rb +2 -2
- data/lib/bundler/checksum.rb +15 -6
- data/lib/bundler/cli/outdated.rb +1 -4
- data/lib/bundler/definition.rb +27 -4
- data/lib/bundler/dependency.rb +17 -2
- data/lib/bundler/dsl.rb +3 -0
- data/lib/bundler/injector.rb +1 -1
- data/lib/bundler/inline.rb +3 -1
- data/lib/bundler/lazy_specification.rb +4 -0
- data/lib/bundler/man/bundle-lock.1 +1 -1
- data/lib/bundler/man/bundle-lock.1.ronn +5 -1
- data/lib/bundler/match_remote_metadata.rb +6 -0
- data/lib/bundler/plugin/index.rb +14 -11
- data/lib/bundler/remote_specification.rb +5 -0
- data/lib/bundler/resolver/candidate.rb +5 -0
- data/lib/bundler/resolver.rb +87 -7
- data/lib/bundler/rubygems_ext.rb +13 -0
- data/lib/bundler/runtime.rb +5 -1
- data/lib/bundler/settings.rb +2 -3
- data/lib/bundler/spec_set.rb +28 -7
- data/lib/bundler/vendored_securerandom.rb +5 -2
- data/lib/bundler/vendored_uri.rb +18 -3
- data/lib/bundler/version.rb +1 -1
- data/lib/rubygems/vendor/pub_grub/lib/pub_grub/term.rb +1 -1
- data/lib/rubygems/yaml_serializer/builder.rb +261 -0
- data/lib/rubygems/yaml_serializer/core.rb +41 -0
- data/lib/rubygems/yaml_serializer/emitter.rb +197 -0
- data/lib/rubygems/yaml_serializer/nodes.rb +10 -0
- data/lib/rubygems/{yaml_serializer.rb → yaml_serializer/parser.rb} +17 -476
- data/lib/rubygems/yaml_serializer/psych_errors.rb +11 -0
- metadata +8 -4
- data/lib/rubygems/vendor/uri/lib/uri.rb +0 -108
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: be084687aeb1aa75ca642df834adb3f7bdcc2e14c55ce43bf65fc25a1aaa1853
|
|
4
|
+
data.tar.gz: 4c364d06f7396cf773beb868dffdf791a37861a218f6e0129c8631751432804c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb8154799e4ffbd7558119749d5a8b79b0135784267130879e2b7c98ceb26e4c1542e607f8770b954dd27b3a54c264d21e95a16fb3980365bb5baae71215fae0
|
|
7
|
+
data.tar.gz: d6695fef513f98c355708242238299f8907049aeb796e8de700060256994de5cb0251e4dfa19a1ecbdcc30764e1616edb36e58ea11543d9650bc4ea6d10f30c2
|
data/bundler.gemspec
CHANGED
|
@@ -42,11 +42,13 @@ Gem::Specification.new do |s|
|
|
|
42
42
|
# Bundler reuses RubyGems' vendored URI, SecureRandom and PubGrub, its
|
|
43
43
|
# pure-Ruby YAML serializer, its shared cooldown setting rules, its compact
|
|
44
44
|
# index client and its credential store. Ship a copy under lib/rubygems so
|
|
45
|
-
# Bundler stays self-contained on RubyGems versions that predate them.
|
|
46
|
-
|
|
45
|
+
# Bundler stays self-contained on RubyGems versions that predate them. The
|
|
46
|
+
# URI and YAML serializer entry files stay out, see
|
|
47
|
+
# lib/rubygems/yaml_serializer/core.rb.
|
|
48
|
+
s.files += Dir.glob("lib/rubygems/vendor/uri/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) || f == "lib/rubygems/vendor/uri/lib/uri.rb" }
|
|
47
49
|
s.files += Dir.glob("lib/rubygems/vendor/securerandom/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
|
|
48
50
|
s.files += Dir.glob("lib/rubygems/vendor/pub_grub/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
|
|
49
|
-
s.files += Dir.glob("lib/rubygems/yaml_serializer
|
|
51
|
+
s.files += Dir.glob("lib/rubygems/yaml_serializer/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
|
|
50
52
|
s.files += Dir.glob("lib/rubygems/cooldown_settings.rb")
|
|
51
53
|
s.files += Dir.glob("lib/rubygems/compact_index_client{.rb,/**/*}", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
|
|
52
54
|
s.files += Dir.glob("lib/rubygems/credential_store{.rb,/**/*}", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
|
|
@@ -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 = "2026-11-
|
|
8
|
-
@git_commit_sha = "
|
|
7
|
+
@built_at = "2026-11-25".freeze
|
|
8
|
+
@git_commit_sha = "8a4df2c".freeze
|
|
9
9
|
# end ivars
|
|
10
10
|
|
|
11
11
|
# A hash representation of the build metadata.
|
data/lib/bundler/checksum.rb
CHANGED
|
@@ -205,20 +205,25 @@ module Bundler
|
|
|
205
205
|
end
|
|
206
206
|
end
|
|
207
207
|
|
|
208
|
+
# A content-addressed row without a digest is an empty entry, like a
|
|
209
|
+
# CHECKSUMS line without one, so it is filled only when a remote fetch
|
|
210
|
+
# can do so (see Definition#empty_checksums_actionable?).
|
|
208
211
|
def missing?(spec)
|
|
209
212
|
return false unless @store[spec.full_name].nil?
|
|
210
213
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
content_addressed_full_names(spec).empty?
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def locked?(spec)
|
|
218
|
+
@store[spec.full_name]&.each_value&.any? {|checksum| checksum.sources.any? {|source| source.type == :lock } } || false
|
|
216
219
|
end
|
|
217
220
|
|
|
218
221
|
def empty?(spec)
|
|
219
222
|
return false unless spec.source.is_a?(Bundler::Source::Rubygems)
|
|
220
223
|
|
|
221
|
-
@store[spec.full_name]&.empty?
|
|
224
|
+
return true if @store[spec.full_name]&.empty?
|
|
225
|
+
|
|
226
|
+
content_addressed_full_names(spec).any? {|full_name| @store[full_name].nil? }
|
|
222
227
|
end
|
|
223
228
|
|
|
224
229
|
def register(spec, checksum)
|
|
@@ -252,6 +257,10 @@ module Bundler
|
|
|
252
257
|
|
|
253
258
|
private
|
|
254
259
|
|
|
260
|
+
def content_addressed_full_names(spec)
|
|
261
|
+
spec.is_a?(LazySpecification) ? spec.content_addressed_full_names : []
|
|
262
|
+
end
|
|
263
|
+
|
|
255
264
|
def platform_full_name(spec)
|
|
256
265
|
Gem::NameTuple.new(spec.name, spec.version, spec.platform).full_name
|
|
257
266
|
end
|
data/lib/bundler/cli/outdated.rb
CHANGED
|
@@ -308,10 +308,7 @@ module Bundler
|
|
|
308
308
|
update_present = active_minor > current_minor if options["filter-minor"]
|
|
309
309
|
|
|
310
310
|
if !update_present && options["filter-patch"] && current_minor == active_minor
|
|
311
|
-
|
|
312
|
-
active_patch = get_version_semver_portion_value(active_spec, 2)
|
|
313
|
-
|
|
314
|
-
update_present = active_patch > current_patch
|
|
311
|
+
update_present = active_spec.version > current_spec.version
|
|
315
312
|
end
|
|
316
313
|
end
|
|
317
314
|
|
data/lib/bundler/definition.rb
CHANGED
|
@@ -213,7 +213,8 @@ module Bundler
|
|
|
213
213
|
sources.remote!
|
|
214
214
|
true
|
|
215
215
|
else
|
|
216
|
-
|
|
216
|
+
# A locked local install skips the missing specs check that preloads Git sources.
|
|
217
|
+
preload_git_sources if options[:local] && no_resolve_needed?
|
|
217
218
|
sources.local!
|
|
218
219
|
false
|
|
219
220
|
end
|
|
@@ -845,6 +846,8 @@ module Bundler
|
|
|
845
846
|
incomplete_specs = still_incomplete_specs
|
|
846
847
|
end
|
|
847
848
|
|
|
849
|
+
check_content_address_fallback_checksums!(specs)
|
|
850
|
+
|
|
848
851
|
insecurely_materialized_specs = resolve.insecurely_materialized_specs
|
|
849
852
|
|
|
850
853
|
if insecurely_materialized_specs.any?
|
|
@@ -860,6 +863,26 @@ module Bundler
|
|
|
860
863
|
specs
|
|
861
864
|
end
|
|
862
865
|
|
|
866
|
+
# The lockfile writes no CHECKSUMS entry for a platform gem it locks only
|
|
867
|
+
# content-addressed gems of, so nothing would verify the platform gem a
|
|
868
|
+
# frozen bundle falls back to under a Ruby ABI the lockfile does not cover.
|
|
869
|
+
def check_content_address_fallback_checksums!(specs)
|
|
870
|
+
return unless Bundler.frozen_bundle? && @locked_checksums
|
|
871
|
+
|
|
872
|
+
unchecksummed_specs = specs.select do |spec|
|
|
873
|
+
!spec.is_a?(StubSpecification) &&
|
|
874
|
+
!Gem::ContentAddress.content_addressed?(spec, validate_ruby_abi: false) &&
|
|
875
|
+
resolve[spec.name].any? {|locked_spec| locked_spec.content_addresses.any? } &&
|
|
876
|
+
!spec.source.checksum_store.locked?(spec)
|
|
877
|
+
end
|
|
878
|
+
return if unchecksummed_specs.empty?
|
|
879
|
+
|
|
880
|
+
raise ProductionError, "Your lockfile has no checksum for #{unchecksummed_specs.map(&:full_name).join(", ")}, " \
|
|
881
|
+
"which would be installed in place of the content-addressed gems it locks, " \
|
|
882
|
+
"but frozen mode is set.\n\n" \
|
|
883
|
+
"Run `bundle install` elsewhere and add the updated Gemfile.lock to version control."
|
|
884
|
+
end
|
|
885
|
+
|
|
863
886
|
def reresolve_without(incomplete_specs)
|
|
864
887
|
resolution_base.delete(incomplete_specs)
|
|
865
888
|
@resolve = start_resolution
|
|
@@ -876,10 +899,10 @@ module Bundler
|
|
|
876
899
|
@resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version
|
|
877
900
|
|
|
878
901
|
@new_platforms.each do |platform|
|
|
879
|
-
incomplete_specs = result.incomplete_specs_for_platform(
|
|
902
|
+
incomplete_specs = result.incomplete_specs_for_platform(dependencies, platform)
|
|
880
903
|
|
|
881
904
|
if incomplete_specs.any?
|
|
882
|
-
resolver.raise_incomplete! incomplete_specs
|
|
905
|
+
resolver.raise_incomplete! incomplete_specs, platform
|
|
883
906
|
end
|
|
884
907
|
end
|
|
885
908
|
|
|
@@ -892,7 +915,7 @@ module Bundler
|
|
|
892
915
|
end
|
|
893
916
|
|
|
894
917
|
if should_add_extra_platforms?
|
|
895
|
-
result.add_extra_platforms!(platforms)
|
|
918
|
+
result.add_extra_platforms!(platforms, prefer_local: @prefer_local)
|
|
896
919
|
elsif @originally_invalid_platforms.any?
|
|
897
920
|
result.add_originally_invalid_platforms!(platforms, @originally_invalid_platforms)
|
|
898
921
|
end
|
data/lib/bundler/dependency.rb
CHANGED
|
@@ -106,8 +106,8 @@ module Bundler
|
|
|
106
106
|
@expanded_platforms ||= platforms.filter_map {|pl| CurrentRuby::PLATFORM_MAP[pl] }.flatten.uniq
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
-
def should_include?
|
|
110
|
-
should_include && current_env? && current_platform?
|
|
109
|
+
def should_include?(platform = nil)
|
|
110
|
+
should_include && current_env? && (platform ? matches_platform?(platform) : current_platform?)
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
def gemspec_dev_dep?
|
|
@@ -151,5 +151,20 @@ module Bundler
|
|
|
151
151
|
rescue NoMethodError
|
|
152
152
|
requirement != ">= 0"
|
|
153
153
|
end
|
|
154
|
+
|
|
155
|
+
private
|
|
156
|
+
|
|
157
|
+
def matches_platform?(platform)
|
|
158
|
+
return true if platforms.empty?
|
|
159
|
+
|
|
160
|
+
generic = Gem::Platform.generic(platform)
|
|
161
|
+
platforms.any? do |name|
|
|
162
|
+
next false unless [CurrentRuby::PLATFORM_MAP[name]].flatten.include?(generic)
|
|
163
|
+
next Bundler.current_ruby.public_send("#{name}?") if generic == Bundler.generic_local_platform
|
|
164
|
+
|
|
165
|
+
version = name.to_s[/_(\d+)\z/, 1]
|
|
166
|
+
!version || Bundler.current_ruby.public_send("on_#{version}?")
|
|
167
|
+
end
|
|
168
|
+
end
|
|
154
169
|
end
|
|
155
170
|
end
|
data/lib/bundler/dsl.rb
CHANGED
|
@@ -460,12 +460,15 @@ module Bundler
|
|
|
460
460
|
end
|
|
461
461
|
|
|
462
462
|
def with_gemfile(gemfile)
|
|
463
|
+
previous_evaluating_gemfile = Thread.current[:bundler_evaluating_gemfile]
|
|
463
464
|
expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile&.parent)
|
|
464
465
|
original_gemfile = @gemfile
|
|
465
466
|
@gemfile = expanded_gemfile_path
|
|
466
467
|
@gemfiles << expanded_gemfile_path
|
|
468
|
+
Thread.current[:bundler_evaluating_gemfile] = @gemfile
|
|
467
469
|
yield @gemfile.to_s
|
|
468
470
|
ensure
|
|
471
|
+
Thread.current[:bundler_evaluating_gemfile] = previous_evaluating_gemfile
|
|
469
472
|
@gemfile = original_gemfile
|
|
470
473
|
end
|
|
471
474
|
|
data/lib/bundler/injector.rb
CHANGED
|
@@ -41,7 +41,7 @@ module Bundler
|
|
|
41
41
|
|
|
42
42
|
# resolve to see if the new deps broke anything
|
|
43
43
|
@definition = builder.to_definition(lockfile_path, {})
|
|
44
|
-
@definition.
|
|
44
|
+
@definition.resolve_remotely!
|
|
45
45
|
|
|
46
46
|
# since nothing broke, we can add those gems to the gemfile
|
|
47
47
|
append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @deps.any?
|
data/lib/bundler/inline.rb
CHANGED
|
@@ -57,7 +57,8 @@ def gemfile(force_latest_compatible = false, options = {}, &gemfile)
|
|
|
57
57
|
builder = Bundler::Dsl.new
|
|
58
58
|
builder.instance_eval(&gemfile)
|
|
59
59
|
|
|
60
|
-
Bundler.settings
|
|
60
|
+
settings = Bundler.settings
|
|
61
|
+
settings.temporary(deployment: false, frozen: false) do
|
|
61
62
|
definition = builder.to_definition(nil, true)
|
|
62
63
|
definition.validate_runtime!
|
|
63
64
|
|
|
@@ -92,6 +93,7 @@ def gemfile(force_latest_compatible = false, options = {}, &gemfile)
|
|
|
92
93
|
|
|
93
94
|
if installed_in_fork
|
|
94
95
|
Bundler.reset!
|
|
96
|
+
Bundler.instance_variable_set(:@settings, settings)
|
|
95
97
|
Gem::Specification.reset
|
|
96
98
|
Bundler.instance_variable_set(:@bundle_path, Pathname.new(Gem.dir))
|
|
97
99
|
|
|
@@ -209,8 +209,12 @@ module Bundler
|
|
|
209
209
|
# Try platforms in order of preference until finding a compatible spec.
|
|
210
210
|
# Used for legacy lockfiles and as a fallback when the exact locked spec
|
|
211
211
|
# is incompatible. Falls back to frozen bundle behavior if none match.
|
|
212
|
+
#
|
|
213
|
+
# Restricting the candidate platforms is not enough to keep a frozen bundle
|
|
214
|
+
# to the locked platforms, since a ruby gem is installable on any of them.
|
|
212
215
|
def resolve_best_platform(specs, locked_platforms: nil)
|
|
213
216
|
specs = MatchPlatform.select_all_content_address_match(specs, content_addresses)
|
|
217
|
+
specs = specs.select {|spec| locked_platforms.include?(spec.platform) } if locked_platforms
|
|
214
218
|
|
|
215
219
|
find_compatible_platform_spec(specs, locked_platforms: locked_platforms) || frozen_bundle_fallback(specs)
|
|
216
220
|
end
|
|
@@ -31,7 +31,7 @@ Fall back to using the single\-file index of all gems\.
|
|
|
31
31
|
Use the specified gemfile instead of [\fBGemfile(5)\fR][Gemfile(5)]\.
|
|
32
32
|
.TP
|
|
33
33
|
\fB\-\-add\-checksums\fR
|
|
34
|
-
Add checksums to the lockfile\.
|
|
34
|
+
Add checksums to the lockfile\. Checksums are taken from the source's index, or computed from the \fB\.gem\fR file of a gem installed on this machine\. With a source that does not publish checksums, entries for gems not installed here, such as gems for other platforms or content\-addressed gems for other Ruby ABIs, stay empty, and frozen installs reject them\.
|
|
35
35
|
.TP
|
|
36
36
|
\fB\-\-add\-platform=<list>\fR
|
|
37
37
|
Add a new platform to the lockfile, re\-resolving for the addition of that platform\.
|
|
@@ -58,7 +58,11 @@ Lock the gems specified in Gemfile.
|
|
|
58
58
|
Use the specified gemfile instead of [`Gemfile(5)`][Gemfile(5)].
|
|
59
59
|
|
|
60
60
|
* `--add-checksums`:
|
|
61
|
-
Add checksums to the lockfile.
|
|
61
|
+
Add checksums to the lockfile. Checksums are taken from the source's index,
|
|
62
|
+
or computed from the `.gem` file of a gem installed on this machine. With a
|
|
63
|
+
source that does not publish checksums, entries for gems not installed here,
|
|
64
|
+
such as gems for other platforms or content-addressed gems for other Ruby
|
|
65
|
+
ABIs, stay empty, and frozen installs reject them.
|
|
62
66
|
|
|
63
67
|
* `--add-platform=<list>`:
|
|
64
68
|
Add a new platform to the lockfile, re-resolving for the addition of that
|
|
@@ -40,5 +40,11 @@ module Bundler
|
|
|
40
40
|
include MatchMetadata
|
|
41
41
|
|
|
42
42
|
prepend FetchMetadata
|
|
43
|
+
|
|
44
|
+
# Return the original dependency so the resolver can apply the same override to it.
|
|
45
|
+
def incompatible_metadata_dependency(overrides)
|
|
46
|
+
return Gem::Dependency.new("Ruby\0", @required_ruby_version) unless matches_current_ruby_with_overrides?(overrides)
|
|
47
|
+
Gem::Dependency.new("RubyGems\0", @required_rubygems_version) unless matches_current_rubygems_with_overrides?(overrides)
|
|
48
|
+
end
|
|
43
49
|
end
|
|
44
50
|
end
|
data/lib/bundler/plugin/index.rb
CHANGED
|
@@ -171,20 +171,25 @@ module Bundler
|
|
|
171
171
|
|
|
172
172
|
data = index_f.read
|
|
173
173
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
#
|
|
177
|
-
|
|
174
|
+
require_relative "../../rubygems/yaml_serializer/core"
|
|
175
|
+
loaded = Gem::YAMLSerializer.load(data) || {}
|
|
176
|
+
# Empty sections load as nil from index files written by older
|
|
177
|
+
# Bundler versions, which dumped empty hashes as a bare key, and as
|
|
178
|
+
# the string "{}" once a gemrc has made RubyGems < 4.1 load its
|
|
179
|
+
# minimal serializer over the copy shipped with Bundler.
|
|
180
|
+
index = %w[commands hooks load_paths plugin_paths sources].to_h do |key|
|
|
181
|
+
[key, loaded[key].is_a?(Hash) ? loaded[key] : {}]
|
|
182
|
+
end
|
|
178
183
|
|
|
179
184
|
escaping = escaping_plugins(index, base)
|
|
180
|
-
hooks =
|
|
185
|
+
hooks = index["hooks"].transform_values {|names| Array(names) - escaping }
|
|
181
186
|
|
|
182
|
-
@commands.merge!(owned_by(index["commands"]
|
|
187
|
+
@commands.merge!(owned_by(index["commands"], escaping))
|
|
183
188
|
# An event whose plugins all escaped is left out rather than merged in empty.
|
|
184
189
|
@hooks.merge!(hooks.reject {|_, names| names.empty? })
|
|
185
190
|
@load_paths.merge!(named(transform_index_paths(index["load_paths"]) {|p| absolutize_path(p, base) }, escaping))
|
|
186
191
|
@plugin_paths.merge!(named(transform_index_paths(index["plugin_paths"]) {|p| absolutize_path(p, base) }, escaping))
|
|
187
|
-
@sources.merge!(owned_by(index["sources"]
|
|
192
|
+
@sources.merge!(owned_by(index["sources"], escaping)) unless global
|
|
188
193
|
end
|
|
189
194
|
end
|
|
190
195
|
|
|
@@ -202,7 +207,7 @@ module Bundler
|
|
|
202
207
|
"sources" => @sources,
|
|
203
208
|
}
|
|
204
209
|
|
|
205
|
-
|
|
210
|
+
require_relative "../../rubygems/yaml_serializer/core"
|
|
206
211
|
SharedHelpers.filesystem_access(index_file) do |index_f|
|
|
207
212
|
FileUtils.mkdir_p(index_f.dirname)
|
|
208
213
|
File.open(index_f, "w") {|f| f.puts Gem::YAMLSerializer.dump(index) }
|
|
@@ -218,7 +223,7 @@ module Bundler
|
|
|
218
223
|
names = []
|
|
219
224
|
|
|
220
225
|
%w[load_paths plugin_paths].each do |key|
|
|
221
|
-
|
|
226
|
+
index[key].each do |name, value|
|
|
222
227
|
escapes = Array(value).any? do |path|
|
|
223
228
|
!Pathname.new(path).absolute? && !contained_in?(absolutize_path(path, base), base)
|
|
224
229
|
end
|
|
@@ -249,8 +254,6 @@ module Bundler
|
|
|
249
254
|
end
|
|
250
255
|
|
|
251
256
|
def transform_index_paths(paths)
|
|
252
|
-
return {} unless paths
|
|
253
|
-
|
|
254
257
|
paths.transform_values do |value|
|
|
255
258
|
if value.is_a?(Array)
|
|
256
259
|
value.map {|path| yield path }
|
|
@@ -25,6 +25,11 @@ module Bundler
|
|
|
25
25
|
@content_address = content_address
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
# Whether the full index gemspec is already available without a fetch.
|
|
29
|
+
def gemspec_loaded?
|
|
30
|
+
!@_remote_specification.nil?
|
|
31
|
+
end
|
|
32
|
+
|
|
28
33
|
def insecurely_materialized?
|
|
29
34
|
@locked_platform.to_s != @platform.to_s
|
|
30
35
|
end
|
data/lib/bundler/resolver.rb
CHANGED
|
@@ -28,6 +28,7 @@ module Bundler
|
|
|
28
28
|
def start
|
|
29
29
|
@requirements = @base.requirements
|
|
30
30
|
@packages = @base.packages
|
|
31
|
+
@incompatible_specs = {}
|
|
31
32
|
|
|
32
33
|
root, logger = setup_solver
|
|
33
34
|
|
|
@@ -71,6 +72,9 @@ module Bundler
|
|
|
71
72
|
@cached_dependencies = Hash.new do |dependencies, package|
|
|
72
73
|
dependencies[package] = Hash.new do |versions, version|
|
|
73
74
|
deps = version.dependencies.reject {|d| d.name == package.name }
|
|
75
|
+
if incompatible = @incompatible_specs[package.name]
|
|
76
|
+
deps.concat(version.specs.filter_map {|s| incompatible[s.full_name] })
|
|
77
|
+
end
|
|
74
78
|
deps = Override.rewrite_dependencies(@base.overrides, package.name, deps)
|
|
75
79
|
deps = apply_metadata_overrides(deps, package.name)
|
|
76
80
|
versions[version] = to_dependency_hash(deps, @packages)
|
|
@@ -86,8 +90,23 @@ module Bundler
|
|
|
86
90
|
end
|
|
87
91
|
|
|
88
92
|
def solve_versions(root:, logger:)
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
result = loop do
|
|
94
|
+
solver = Gem::PubGrub::VersionSolver.new(source: self, root: root, strategy: Strategy.new(self), logger: logger)
|
|
95
|
+
solution = solver.solve
|
|
96
|
+
|
|
97
|
+
# Some indexes omit Ruby and RubyGems requirements. Fetch them only for
|
|
98
|
+
# selected versions, then solve again if the new requirements conflict.
|
|
99
|
+
incompatible = solution.values.flat_map(&:specs).filter_map do |s|
|
|
100
|
+
next unless s.is_a?(MatchRemoteMetadata)
|
|
101
|
+
dependency = s.incompatible_metadata_dependency(@base.overrides)
|
|
102
|
+
[s, dependency] if dependency
|
|
103
|
+
end
|
|
104
|
+
break solution if incompatible.empty?
|
|
105
|
+
|
|
106
|
+
incompatible.each {|s, dep| (@incompatible_specs[s.name] ||= {})[s.full_name] = dep }
|
|
107
|
+
root, logger = setup_solver
|
|
108
|
+
end
|
|
109
|
+
|
|
91
110
|
resolved_specs = result.flat_map {|package, version| version.to_specs(package, @most_specific_locked_platform) }
|
|
92
111
|
check_replaced_gems(resolved_specs)
|
|
93
112
|
Override.attach(resolved_specs, @base.overrides)
|
|
@@ -180,8 +199,10 @@ module Bundler
|
|
|
180
199
|
names_to_allow_remote_specs_for = []
|
|
181
200
|
extended_explanation = nil
|
|
182
201
|
|
|
202
|
+
satisfiers = []
|
|
183
203
|
while incompatibility.conflict?
|
|
184
204
|
cause = incompatibility.cause
|
|
205
|
+
satisfiers << cause.satisfier
|
|
185
206
|
incompatibility = cause.incompatibility
|
|
186
207
|
|
|
187
208
|
incompatibility.terms.each do |term|
|
|
@@ -190,7 +211,7 @@ module Bundler
|
|
|
190
211
|
|
|
191
212
|
if base_requirements[name]
|
|
192
213
|
names_to_unlock << name
|
|
193
|
-
elsif package
|
|
214
|
+
elsif filtered_prereleases?(package)
|
|
194
215
|
names_to_allow_prereleases_for << name
|
|
195
216
|
elsif package.prefer_local? && @all_specs[name].any? {|s| !s.is_a?(StubSpecification) }
|
|
196
217
|
names_to_allow_remote_specs_for << name
|
|
@@ -203,6 +224,11 @@ module Bundler
|
|
|
203
224
|
end
|
|
204
225
|
end
|
|
205
226
|
|
|
227
|
+
# Preserve the usual retry order when it can already resolve the conflict.
|
|
228
|
+
if names_to_unlock.empty? && names_to_allow_prereleases_for.empty? && names_to_allow_remote_specs_for.empty?
|
|
229
|
+
names_to_allow_prereleases_for = prerelease_names_in(satisfiers)
|
|
230
|
+
end
|
|
231
|
+
|
|
206
232
|
[names_to_unlock.uniq, names_to_allow_prereleases_for.uniq, names_to_allow_remote_specs_for.uniq, extended_explanation]
|
|
207
233
|
end
|
|
208
234
|
|
|
@@ -310,6 +336,17 @@ module Bundler
|
|
|
310
336
|
results = filter_matching_specs(results, locked_requirement) if locked_requirement
|
|
311
337
|
|
|
312
338
|
results.group_by(&:version).reduce([]) do |groups, (version, specs)|
|
|
339
|
+
if rejected = @incompatible_specs[name]
|
|
340
|
+
compatible = specs.reject do |s|
|
|
341
|
+
if s.is_a?(RemoteSpecification) && s.gemspec_loaded?
|
|
342
|
+
rejected[s.full_name] ||= s.incompatible_metadata_dependency(@base.overrides)
|
|
343
|
+
end
|
|
344
|
+
rejected[s.full_name]
|
|
345
|
+
end
|
|
346
|
+
# Keep the conflicting dependencies when PubGrub needs to explain why no build works.
|
|
347
|
+
specs = compatible unless compatible.empty?
|
|
348
|
+
end
|
|
349
|
+
|
|
313
350
|
platform_specs = package.platform_specs(specs)
|
|
314
351
|
|
|
315
352
|
# If package is a top-level dependency,
|
|
@@ -368,8 +405,10 @@ module Bundler
|
|
|
368
405
|
"Gemfile"
|
|
369
406
|
end
|
|
370
407
|
|
|
371
|
-
def raise_incomplete!(incomplete_specs)
|
|
372
|
-
|
|
408
|
+
def raise_incomplete!(incomplete_specs, platform = nil)
|
|
409
|
+
spec = incomplete_specs.first
|
|
410
|
+
# An unresolved dependency may be missing for a different resolution platform.
|
|
411
|
+
raise_not_found!(@base.get_package(spec.name), spec.version && platform)
|
|
373
412
|
end
|
|
374
413
|
|
|
375
414
|
def sort_versions_by_preferred(package, versions)
|
|
@@ -378,7 +417,7 @@ module Bundler
|
|
|
378
417
|
|
|
379
418
|
private
|
|
380
419
|
|
|
381
|
-
def raise_not_found!(package)
|
|
420
|
+
def raise_not_found!(package, platform = nil)
|
|
382
421
|
name = package.name
|
|
383
422
|
source = source_for(name)
|
|
384
423
|
specs = @all_specs[name]
|
|
@@ -394,7 +433,7 @@ module Bundler
|
|
|
394
433
|
not_found_message = if specs_matching_requirement.any?
|
|
395
434
|
specs = specs_matching_requirement
|
|
396
435
|
matching_part = requirement_label
|
|
397
|
-
platforms = package.platforms
|
|
436
|
+
platforms = platform ? [platform] : package.platforms
|
|
398
437
|
|
|
399
438
|
if platforms.size == 1
|
|
400
439
|
"Could not find gem '#{requirement_label}' with platform '#{platforms.first}'"
|
|
@@ -461,6 +500,30 @@ module Bundler
|
|
|
461
500
|
filter_remote_specs(filter_cooldown(filter_prereleases(specs, package)), package)
|
|
462
501
|
end
|
|
463
502
|
|
|
503
|
+
def prerelease_names_in(incompatibilities)
|
|
504
|
+
seen = {}.compare_by_identity
|
|
505
|
+
packages = []
|
|
506
|
+
while (incompatibility = incompatibilities.pop)
|
|
507
|
+
next if seen[incompatibility]
|
|
508
|
+
seen[incompatibility] = true
|
|
509
|
+
|
|
510
|
+
if incompatibility.conflict?
|
|
511
|
+
cause = incompatibility.cause
|
|
512
|
+
incompatibilities.push(cause.incompatibility, cause.satisfier)
|
|
513
|
+
else
|
|
514
|
+
incompatibility.terms.each {|term| packages << term.package }
|
|
515
|
+
end
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
packages.uniq.filter_map do |package|
|
|
519
|
+
package.name if !base_requirements[package.name] && filtered_prereleases?(package)
|
|
520
|
+
end
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
def filtered_prereleases?(package)
|
|
524
|
+
package.ignores_prereleases? && @all_specs[package.name].any? {|s| s.version.prerelease? }
|
|
525
|
+
end
|
|
526
|
+
|
|
464
527
|
def filter_prereleases(specs, package)
|
|
465
528
|
return specs unless package.ignores_prereleases? && specs.size > 1
|
|
466
529
|
|
|
@@ -620,6 +683,13 @@ module Bundler
|
|
|
620
683
|
versions = versions_for(dep_package, dep_range)
|
|
621
684
|
end
|
|
622
685
|
|
|
686
|
+
if versions.empty? && locked_version_missing?(dep_package)
|
|
687
|
+
@base.unlock_names([name])
|
|
688
|
+
@all_versions.delete(dep_package)
|
|
689
|
+
@sorted_versions.delete(dep_package)
|
|
690
|
+
versions = versions_for(dep_package, dep_range)
|
|
691
|
+
end
|
|
692
|
+
|
|
623
693
|
if versions.empty? && select_all_versions(dep_package, dep_range).any?
|
|
624
694
|
raise_all_versions_filtered_out!(dep_package)
|
|
625
695
|
end
|
|
@@ -632,6 +702,16 @@ module Bundler
|
|
|
632
702
|
end.to_h
|
|
633
703
|
end
|
|
634
704
|
|
|
705
|
+
def locked_version_missing?(package)
|
|
706
|
+
return false unless package.unlock?
|
|
707
|
+
|
|
708
|
+
name = package.name
|
|
709
|
+
version = package.locked_version
|
|
710
|
+
return false unless base_requirements[name]&.requirements == [[">=", version]]
|
|
711
|
+
|
|
712
|
+
source_for(name).specs.search([name, version]).empty?
|
|
713
|
+
end
|
|
714
|
+
|
|
635
715
|
def select_all_versions(package, range)
|
|
636
716
|
range.select_versions(@all_versions[package])
|
|
637
717
|
end
|
data/lib/bundler/rubygems_ext.rb
CHANGED
|
@@ -280,6 +280,19 @@ module Gem
|
|
|
280
280
|
|
|
281
281
|
prepend AllowSettingSource
|
|
282
282
|
|
|
283
|
+
module TrackGemfileActivation
|
|
284
|
+
# The Gemfile being evaluated when RubyGems activated this spec.
|
|
285
|
+
attr_reader :bundler_activating_gemfile
|
|
286
|
+
|
|
287
|
+
def activate
|
|
288
|
+
activated = super
|
|
289
|
+
@bundler_activating_gemfile = Thread.current[:bundler_evaluating_gemfile] if activated
|
|
290
|
+
activated
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
prepend TrackGemfileActivation
|
|
295
|
+
|
|
283
296
|
alias_method :rg_full_gem_path, :full_gem_path
|
|
284
297
|
alias_method :rg_loaded_from, :loaded_from
|
|
285
298
|
|
data/lib/bundler/runtime.rb
CHANGED
|
@@ -395,7 +395,11 @@ module Bundler
|
|
|
395
395
|
return unless activated_spec = Bundler.rubygems.loaded_specs(spec.name)
|
|
396
396
|
return if activated_spec.version == spec.version
|
|
397
397
|
|
|
398
|
-
|
|
398
|
+
activating_gemfile = activated_spec.bundler_activating_gemfile if activated_spec.respond_to?(:bundler_activating_gemfile)
|
|
399
|
+
suggestion = if @definition.gemfiles.include?(activating_gemfile)
|
|
400
|
+
"#{spec.name} was activated while evaluating your Gemfile. If a `require` in your Gemfile loads it, " \
|
|
401
|
+
"remove that call or move it outside the Gemfile, after `Bundler.setup`."
|
|
402
|
+
elsif activated_spec.default_gem?
|
|
399
403
|
"Since #{spec.name} is a default gem, you can either remove your dependency on it" \
|
|
400
404
|
" or try updating to a newer version of bundler that supports #{spec.name} as a default gem."
|
|
401
405
|
else
|
data/lib/bundler/settings.rb
CHANGED
|
@@ -826,9 +826,8 @@ module Bundler
|
|
|
826
826
|
end
|
|
827
827
|
|
|
828
828
|
def serializer_class
|
|
829
|
-
#
|
|
830
|
-
|
|
831
|
-
require "rubygems/yaml_serializer"
|
|
829
|
+
# See lib/rubygems/yaml_serializer/core.rb.
|
|
830
|
+
require_relative "../rubygems/yaml_serializer/core"
|
|
832
831
|
Gem::YAMLSerializer
|
|
833
832
|
end
|
|
834
833
|
|