rubygems-update 4.1.0.beta2 → 4.1.0
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/CHANGELOG.md +136 -94
- data/Manifest.txt +1 -1
- data/lib/bundler/build_metadata.rb +2 -2
- data/lib/bundler/checksum.rb +8 -2
- data/lib/bundler/cli/clean.rb +19 -3
- data/lib/bundler/cli/exec.rb +1 -1
- data/lib/bundler/cli/install.rb +1 -1
- data/lib/bundler/cli/lock.rb +17 -1
- data/lib/bundler/cli/update.rb +1 -1
- data/lib/bundler/cli.rb +2 -0
- data/lib/bundler/definition.rb +170 -12
- data/lib/bundler/dsl.rb +40 -23
- data/lib/bundler/errors.rb +8 -0
- data/lib/bundler/fetcher/downloader.rb +15 -5
- data/lib/bundler/fetcher.rb +4 -1
- data/lib/bundler/index.rb +7 -2
- data/lib/bundler/inline.rb +16 -8
- data/lib/bundler/installer.rb +19 -0
- data/lib/bundler/lazy_specification.rb +42 -25
- data/lib/bundler/lockfile_generator.rb +27 -9
- data/lib/bundler/lockfile_parser.rb +38 -6
- data/lib/bundler/man/bundle-lock.1 +7 -1
- data/lib/bundler/man/bundle-lock.1.ronn +10 -0
- data/lib/bundler/man/bundle-plugin.1 +61 -0
- data/lib/bundler/man/bundle-plugin.1.ronn +84 -0
- data/lib/bundler/man/gemfile.5 +21 -10
- data/lib/bundler/man/gemfile.5.ronn +39 -17
- data/lib/bundler/match_platform.rb +15 -6
- data/lib/bundler/mirror.rb +7 -5
- data/lib/bundler/override.rb +60 -7
- data/lib/bundler/resolver.rb +3 -1
- data/lib/bundler/ruby_dsl.rb +2 -1
- data/lib/bundler/rubygems_ext.rb +56 -13
- data/lib/bundler/rubygems_integration.rb +2 -4
- data/lib/bundler/runtime.rb +24 -10
- data/lib/bundler/source/git/git_proxy.rb +18 -6
- data/lib/bundler/source/git.rb +0 -2
- data/lib/bundler/source/rubygems.rb +2 -2
- data/lib/bundler/source_map.rb +1 -1
- data/lib/bundler/spec_set.rb +26 -7
- data/lib/bundler/stub_specification.rb +4 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +54 -29
- data/lib/bundler/version.rb +1 -1
- data/lib/bundler/worker.rb +4 -0
- data/lib/bundler.rb +1 -1
- data/lib/rubygems/available_set.rb +0 -27
- data/lib/rubygems/command.rb +0 -9
- data/lib/rubygems/commands/sources_command.rb +0 -12
- data/lib/rubygems/compact_index_client/http_fetcher.rb +3 -1
- data/lib/rubygems/compact_index_client/parser.rb +1 -0
- data/lib/rubygems/config_file.rb +7 -4
- data/lib/rubygems/content_address.rb +5 -4
- data/lib/rubygems/dependency_installer.rb +0 -10
- data/lib/rubygems/dependency_list.rb +2 -12
- data/lib/rubygems/ext/builder.rb +8 -4
- data/lib/rubygems/package.rb +3 -0
- data/lib/rubygems/remote_fetcher.rb +1 -1
- data/lib/rubygems/requirement.rb +1 -1
- data/lib/rubygems/resolver/dependency_request.rb +0 -8
- data/lib/rubygems/safe_marshal/visitors/to_ruby.rb +11 -6
- data/lib/rubygems/safe_yaml.rb +33 -3
- data/lib/rubygems/specification_policy.rb +14 -10
- data/lib/rubygems/uninstaller.rb +14 -2
- data/lib/rubygems/user_interaction.rb +6 -9
- data/lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb +10 -1
- data/lib/rubygems/vendor/net-http/lib/net/http/header.rb +56 -15
- data/lib/rubygems/vendor/net-http/lib/net/http/request.rb +1 -0
- data/lib/rubygems/vendor/net-http/lib/net/http/requests.rb +59 -24
- data/lib/rubygems/vendor/net-http/lib/net/http/response.rb +40 -15
- data/lib/rubygems/vendor/net-http/lib/net/http.rb +73 -14
- data/lib/rubygems/vendor/net-protocol/COPYING +56 -0
- data/lib/rubygems/vendor/net-protocol/lib/net/protocol.rb +95 -26
- data/lib/rubygems/vendor/uri/lib/uri/common.rb +1 -1
- data/lib/rubygems/vendor/uri/lib/uri/generic.rb +15 -3
- data/lib/rubygems/vendor/uri/lib/uri/version.rb +1 -1
- data/lib/rubygems/yaml_serializer.rb +247 -137
- data/lib/rubygems.rb +23 -7
- metadata +9 -9
- data/lib/rubygems/vendor/net-protocol/LICENSE.txt +0 -22
data/lib/bundler/definition.rb
CHANGED
|
@@ -104,6 +104,8 @@ module Bundler
|
|
|
104
104
|
@new_platforms = []
|
|
105
105
|
@removed_platforms = []
|
|
106
106
|
@originally_invalid_platforms = []
|
|
107
|
+
@new_ruby_abis = []
|
|
108
|
+
@removed_ruby_abis = []
|
|
107
109
|
|
|
108
110
|
if lockfile_exists?
|
|
109
111
|
@lockfile_contents = Bundler.read_file(lockfile)
|
|
@@ -111,6 +113,8 @@ module Bundler
|
|
|
111
113
|
@locked_platforms = @locked_gems.platforms
|
|
112
114
|
@most_specific_locked_platform = @locked_gems.most_specific_locked_platform
|
|
113
115
|
@platforms = @locked_platforms.dup
|
|
116
|
+
@locked_ruby_abis = @locked_gems.ruby_abis
|
|
117
|
+
@ruby_abis = @locked_ruby_abis.dup
|
|
114
118
|
@locked_bundler_version = @locked_gems.bundler_version
|
|
115
119
|
@locked_ruby_version = @locked_gems.ruby_version
|
|
116
120
|
@locked_deps = @locked_gems.dependencies
|
|
@@ -139,7 +143,9 @@ module Bundler
|
|
|
139
143
|
@locked_gems = nil
|
|
140
144
|
@locked_platforms = []
|
|
141
145
|
@most_specific_locked_platform = nil
|
|
142
|
-
@platforms
|
|
146
|
+
@platforms = []
|
|
147
|
+
@locked_ruby_abis = []
|
|
148
|
+
@ruby_abis = []
|
|
143
149
|
@locked_deps = {}
|
|
144
150
|
@locked_specs = SpecSet.new([])
|
|
145
151
|
@locked_sources = []
|
|
@@ -153,7 +159,11 @@ module Bundler
|
|
|
153
159
|
end
|
|
154
160
|
@unlocking ||= @unlocking_ruby ||= (!@locked_ruby_version ^ !@ruby_version)
|
|
155
161
|
|
|
162
|
+
@excluded_ruby_abis = @ruby_version && content_addressing_supported? ? @ruby_abis.select {|ruby_abi| ruby_abi_excluded?(ruby_abi) } : []
|
|
163
|
+
@ruby_abis -= @excluded_ruby_abis
|
|
164
|
+
|
|
156
165
|
@current_platform_missing = add_current_platform unless Bundler.frozen_bundle?
|
|
166
|
+
@current_ruby_abi_missing = add_current_ruby_abi unless Bundler.frozen_bundle?
|
|
157
167
|
|
|
158
168
|
@source_changes = converge_sources
|
|
159
169
|
@path_changes = converge_paths
|
|
@@ -167,6 +177,7 @@ module Bundler
|
|
|
167
177
|
|
|
168
178
|
@dependency_changes = converge_dependencies
|
|
169
179
|
@local_changes = converge_locals
|
|
180
|
+
@override_changes = converge_overrides
|
|
170
181
|
|
|
171
182
|
check_lockfile
|
|
172
183
|
end
|
|
@@ -369,6 +380,7 @@ module Bundler
|
|
|
369
380
|
start_resolution
|
|
370
381
|
end
|
|
371
382
|
warn_inert_overrides(@resolve)
|
|
383
|
+
@resolve.assign_content_addresses!(@ruby_abis, local: sources.local_mode?) if @removed_ruby_abis.any?
|
|
372
384
|
@resolve
|
|
373
385
|
end
|
|
374
386
|
|
|
@@ -477,6 +489,11 @@ module Bundler
|
|
|
477
489
|
@resolved_bundler_version || Bundler.gem_version
|
|
478
490
|
end
|
|
479
491
|
|
|
492
|
+
# The lines for the OVERRIDES section of Gemfile.lock.
|
|
493
|
+
def overrides_to_lock
|
|
494
|
+
@overrides.map(&:to_lock).uniq
|
|
495
|
+
end
|
|
496
|
+
|
|
480
497
|
def to_lock
|
|
481
498
|
require_relative "lockfile_generator"
|
|
482
499
|
LockfileGenerator.generate(self)
|
|
@@ -537,6 +554,32 @@ module Bundler
|
|
|
537
554
|
resolve.normalize_platforms!(current_dependencies, platforms)
|
|
538
555
|
|
|
539
556
|
@resolve = SpecSet.new(resolve.for(current_dependencies, @platforms))
|
|
557
|
+
@resolve.assign_content_addresses!(@ruby_abis, normalize: true)
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
def ruby_abis
|
|
561
|
+
return [] unless content_addressing_supported? || content_addresses_carried_over?
|
|
562
|
+
|
|
563
|
+
@ruby_abis.sort_by {|ruby_abi| Gem::Version.new(ruby_abi) }
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
def add_ruby_abi(ruby_abi)
|
|
567
|
+
ensure_content_addressing_supported!
|
|
568
|
+
if @ruby_version && ruby_abi_excluded?(ruby_abi)
|
|
569
|
+
raise InvalidOption, "Unable to add the Ruby ABI `#{ruby_abi}` since your Gemfile requires #{@ruby_version}"
|
|
570
|
+
end
|
|
571
|
+
return if @locked_ruby_abis.include?(ruby_abi) || @new_ruby_abis.include?(ruby_abi)
|
|
572
|
+
|
|
573
|
+
@new_ruby_abis << ruby_abi
|
|
574
|
+
@ruby_abis |= [ruby_abi]
|
|
575
|
+
end
|
|
576
|
+
|
|
577
|
+
def remove_ruby_abi(ruby_abi)
|
|
578
|
+
ensure_content_addressing_supported!
|
|
579
|
+
raise InvalidOption, "Unable to remove the Ruby ABI `#{ruby_abi}` since the only Ruby ABIs are #{ruby_abis.join(", ")}" unless @ruby_abis.include?(ruby_abi)
|
|
580
|
+
|
|
581
|
+
@removed_ruby_abis << ruby_abi
|
|
582
|
+
@ruby_abis.delete(ruby_abi)
|
|
540
583
|
end
|
|
541
584
|
|
|
542
585
|
def add_platform(platform)
|
|
@@ -595,10 +638,17 @@ module Bundler
|
|
|
595
638
|
|
|
596
639
|
added.concat @new_platforms.map {|p| "* platform: #{p}" }
|
|
597
640
|
deleted.concat @removed_platforms.map {|p| "* platform: #{p}" }
|
|
641
|
+
added.concat @new_ruby_abis.map {|abi| "* ruby abi: #{abi}" }
|
|
642
|
+
deleted.concat @removed_ruby_abis.map {|abi| "* ruby abi: #{abi}" }
|
|
598
643
|
|
|
599
644
|
added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
|
|
600
645
|
deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
|
|
601
646
|
|
|
647
|
+
if @override_changes
|
|
648
|
+
added.concat((overrides_to_lock - locked_overrides_to_lock).sort.map {|o| "* override #{o}" })
|
|
649
|
+
deleted.concat((locked_overrides_to_lock - overrides_to_lock).sort.map {|o| "* override #{o}" })
|
|
650
|
+
end
|
|
651
|
+
|
|
602
652
|
both_sources = Hash.new {|h, k| h[k] = [] }
|
|
603
653
|
current_dependencies.each {|d| both_sources[d.name][0] = d }
|
|
604
654
|
current_locked_dependencies.each {|d| both_sources[d.name][1] = d }
|
|
@@ -649,6 +699,9 @@ module Bundler
|
|
|
649
699
|
@dependency_changes ||
|
|
650
700
|
@current_platform_missing ||
|
|
651
701
|
@new_platforms.any? ||
|
|
702
|
+
@current_ruby_abi_missing ||
|
|
703
|
+
@new_ruby_abis.any? ||
|
|
704
|
+
@excluded_ruby_abis.any? ||
|
|
652
705
|
@path_changes ||
|
|
653
706
|
@local_changes ||
|
|
654
707
|
@missing_lockfile_dep ||
|
|
@@ -776,7 +829,9 @@ module Bundler
|
|
|
776
829
|
loop do
|
|
777
830
|
break if incomplete_specs.empty?
|
|
778
831
|
|
|
779
|
-
Bundler.ui.debug("The lockfile does not have all gems needed for the current platform though,
|
|
832
|
+
Bundler.ui.debug("The lockfile does not have all gems needed for the current platform (#{Bundler.local_platform}) though, " \
|
|
833
|
+
"Bundler will still re-resolve dependencies. The following locked gems could not be materialized for it: " \
|
|
834
|
+
"#{incomplete_specs.map(&:full_name).join(", ")}")
|
|
780
835
|
sources.remote!
|
|
781
836
|
reresolve_without(incomplete_specs)
|
|
782
837
|
specs = resolve.materialize(dependencies)
|
|
@@ -842,7 +897,22 @@ module Bundler
|
|
|
842
897
|
result.add_originally_invalid_platforms!(platforms, @originally_invalid_platforms)
|
|
843
898
|
end
|
|
844
899
|
|
|
845
|
-
SpecSet.new(result.for(dependencies, @platforms | [Gem::Platform::RUBY]))
|
|
900
|
+
specs = SpecSet.new(result.for(dependencies, @platforms | [Gem::Platform::RUBY]))
|
|
901
|
+
specs.assign_content_addresses!(@ruby_abis, local: sources.local_mode?)
|
|
902
|
+
|
|
903
|
+
if sources.local_mode?
|
|
904
|
+
# Only installed gems are in reach, so a Ruby is recorded once every row
|
|
905
|
+
# has its gem; the running Ruby otherwise waits for the next online resolution.
|
|
906
|
+
@ruby_abis.delete(Gem.ruby_abi) if @current_ruby_abi_missing && !specs.content_addresses_cover?(Gem.ruby_abi)
|
|
907
|
+
|
|
908
|
+
@new_ruby_abis.each do |ruby_abi|
|
|
909
|
+
next if specs.content_addresses_cover?(ruby_abi)
|
|
910
|
+
|
|
911
|
+
raise GemNotFound, "Could not find content-addressed gems for Ruby ABI #{ruby_abi} in locally installed gems"
|
|
912
|
+
end
|
|
913
|
+
end
|
|
914
|
+
|
|
915
|
+
specs
|
|
846
916
|
end
|
|
847
917
|
|
|
848
918
|
def precompute_source_requirements_for_indirect_dependencies?
|
|
@@ -883,6 +953,66 @@ module Bundler
|
|
|
883
953
|
true
|
|
884
954
|
end
|
|
885
955
|
|
|
956
|
+
def add_current_ruby_abi
|
|
957
|
+
return unless content_addressing_supported?
|
|
958
|
+
return if @ruby_abis.include?(Gem.ruby_abi)
|
|
959
|
+
|
|
960
|
+
@ruby_abis << Gem.ruby_abi
|
|
961
|
+
@locked_specs.any? {|spec| spec.content_addresses.any? }
|
|
962
|
+
end
|
|
963
|
+
|
|
964
|
+
# RubyGems before 4.1 can't lock content-addressed gems, so changing the
|
|
965
|
+
# locked Ruby ABIs there would leave CONTENT ADDRESSES out of step with them.
|
|
966
|
+
def content_addressing_supported?
|
|
967
|
+
Bundler.rubygems.provides?(">= 4.1.0.a")
|
|
968
|
+
end
|
|
969
|
+
|
|
970
|
+
def ensure_content_addressing_supported!
|
|
971
|
+
return if content_addressing_supported?
|
|
972
|
+
|
|
973
|
+
raise InvalidOption, "Changing the Ruby ABIs in the lockfile requires RubyGems 4.1.0 or later, but you are using RubyGems #{Bundler.rubygems.version}"
|
|
974
|
+
end
|
|
975
|
+
|
|
976
|
+
# Older RubyGems resolves platform gems without the content addresses the
|
|
977
|
+
# lockfile had for them, and may swap a locked one for its ruby variant. Unless
|
|
978
|
+
# every platform gem comes through as locked, the lockfile then drops its Ruby
|
|
979
|
+
# ABIs, so that RubyGems 4.1 resolves again and records the content addresses
|
|
980
|
+
# instead of falling back.
|
|
981
|
+
def content_addresses_carried_over?
|
|
982
|
+
locked = @originally_locked_specs.select {|spec| spec.platform != Gem::Platform::RUBY && resolve[spec.name].any? }
|
|
983
|
+
resolved = resolve.select {|spec| spec.platform != Gem::Platform::RUBY }
|
|
984
|
+
|
|
985
|
+
locked.to_h {|spec| [spec.full_name, spec.content_addresses] } == resolved.to_h {|spec| [spec.full_name, spec.content_addresses] }
|
|
986
|
+
end
|
|
987
|
+
|
|
988
|
+
def ruby_abi_excluded?(ruby_abi)
|
|
989
|
+
comparators = Gem::Requirement.new(@ruby_version.versions).requirements +
|
|
990
|
+
Gem::ContentAddress.ruby_abi_requirement(ruby_abi).requirements
|
|
991
|
+
|
|
992
|
+
lower = []
|
|
993
|
+
upper = []
|
|
994
|
+
comparators.each do |op, version|
|
|
995
|
+
case op
|
|
996
|
+
when ">=" then lower << [version, true]
|
|
997
|
+
when ">" then lower << [version, false]
|
|
998
|
+
when "<=" then upper << [version, true]
|
|
999
|
+
when "<" then upper << [version, false]
|
|
1000
|
+
when "="
|
|
1001
|
+
lower << [version, true]
|
|
1002
|
+
upper << [version, true]
|
|
1003
|
+
when "~>"
|
|
1004
|
+
lower << [version, true]
|
|
1005
|
+
upper << [Gem::Version.new("#{version.bump}.A"), false]
|
|
1006
|
+
end
|
|
1007
|
+
end
|
|
1008
|
+
return false if lower.empty? || upper.empty?
|
|
1009
|
+
|
|
1010
|
+
min, min_inclusive = lower.max_by {|version, inclusive| [version, inclusive ? 0 : 1] }
|
|
1011
|
+
max, max_inclusive = upper.min_by {|version, inclusive| [version, inclusive ? 1 : 0] }
|
|
1012
|
+
|
|
1013
|
+
min > max || (min == max && !(min_inclusive && max_inclusive))
|
|
1014
|
+
end
|
|
1015
|
+
|
|
886
1016
|
def find_most_specific_locked_platform
|
|
887
1017
|
return unless current_platform_locked?
|
|
888
1018
|
|
|
@@ -908,6 +1038,8 @@ module Bundler
|
|
|
908
1038
|
else
|
|
909
1039
|
lockfile_changed_reason
|
|
910
1040
|
end
|
|
1041
|
+
elsif @override_changes
|
|
1042
|
+
"the overrides in your gemfile changed"
|
|
911
1043
|
else
|
|
912
1044
|
"some dependencies were deleted from your gemfile"
|
|
913
1045
|
end
|
|
@@ -935,6 +1067,9 @@ module Bundler
|
|
|
935
1067
|
[@dependency_changes, "the dependencies in your gemfile changed"],
|
|
936
1068
|
[@current_platform_missing, "your lockfile is missing the current platform"],
|
|
937
1069
|
[@new_platforms.any?, "you are adding a new platform to your lockfile"],
|
|
1070
|
+
[@new_ruby_abis.any?, "you are adding a new Ruby ABI to your lockfile"],
|
|
1071
|
+
[@current_ruby_abi_missing, "your lockfile does not cover the current Ruby ABI"],
|
|
1072
|
+
[@excluded_ruby_abis.any?, "your Gemfile's ruby directive rules out Ruby ABIs in your lockfile"],
|
|
938
1073
|
[@path_changes, "the gemspecs for path gems changed"],
|
|
939
1074
|
[@local_changes, "the gemspecs for git local gems changed"],
|
|
940
1075
|
[@missing_lockfile_dep, "your lockfile is missing \"#{@missing_lockfile_dep}\""],
|
|
@@ -943,6 +1078,7 @@ module Bundler
|
|
|
943
1078
|
[@locked_spec_with_empty_checksums, "your lockfile has an empty CHECKSUMS entry for \"#{@locked_spec_with_empty_checksums}\""],
|
|
944
1079
|
[@locked_spec_with_missing_deps, "your lockfile includes \"#{@locked_spec_with_missing_deps}\" but not some of its dependencies"],
|
|
945
1080
|
[@locked_spec_with_invalid_deps, "your lockfile does not satisfy dependencies of \"#{@locked_spec_with_invalid_deps}\""],
|
|
1081
|
+
[@override_changes, "the overrides in your gemfile changed"],
|
|
946
1082
|
].select(&:first).map(&:last).join(", ")
|
|
947
1083
|
end
|
|
948
1084
|
|
|
@@ -1115,7 +1251,7 @@ module Bundler
|
|
|
1115
1251
|
end
|
|
1116
1252
|
|
|
1117
1253
|
# The lockfile keeps the upstream dependencies of every gem, so a gem that
|
|
1118
|
-
# a `
|
|
1254
|
+
# a `with:`/`in:` override cut loose stays locked until a resolution drops
|
|
1119
1255
|
# it.
|
|
1120
1256
|
def converge_rewritten_dependencies
|
|
1121
1257
|
@overrides.each do |override|
|
|
@@ -1135,7 +1271,7 @@ module Bundler
|
|
|
1135
1271
|
end
|
|
1136
1272
|
end
|
|
1137
1273
|
|
|
1138
|
-
# A misspelled `
|
|
1274
|
+
# A misspelled `in:` gem leaves the override with nothing to rewrite.
|
|
1139
1275
|
def warn_inert_overrides(specs)
|
|
1140
1276
|
@overrides.each do |override|
|
|
1141
1277
|
next unless override.from
|
|
@@ -1145,13 +1281,29 @@ module Bundler
|
|
|
1145
1281
|
end
|
|
1146
1282
|
end
|
|
1147
1283
|
|
|
1284
|
+
# The lockfile records the Gemfile's overrides, so a change to them is a
|
|
1285
|
+
# change to the lockfile even when every locked version still satisfies
|
|
1286
|
+
# them. Rewriting the section needs no resolution, so this stays out of
|
|
1287
|
+
# #something_changed?. #write_lock rewrites it because the generated
|
|
1288
|
+
# contents differ, and the frozen check reports it.
|
|
1289
|
+
def converge_overrides
|
|
1290
|
+
return false unless @locked_gems
|
|
1291
|
+
|
|
1292
|
+
overrides_to_lock.sort != locked_overrides_to_lock.sort
|
|
1293
|
+
end
|
|
1294
|
+
|
|
1295
|
+
def locked_overrides_to_lock
|
|
1296
|
+
Array(@locked_gems&.overrides).map(&:to_lock).uniq
|
|
1297
|
+
end
|
|
1298
|
+
|
|
1148
1299
|
def converge_overrides_outside_dependencies
|
|
1149
1300
|
@overrides.each do |override|
|
|
1150
|
-
# :all and metadata overrides are intentionally not pre-unlocked.
|
|
1151
|
-
#
|
|
1152
|
-
#
|
|
1153
|
-
#
|
|
1154
|
-
#
|
|
1301
|
+
# :all and metadata overrides are intentionally not pre-unlocked.
|
|
1302
|
+
# Unlocking for them would re-resolve gems the user did not ask to
|
|
1303
|
+
# move. Install-time compatibility checks already honor them for locked
|
|
1304
|
+
# specs, and they affect resolution on a fresh lock or when the user
|
|
1305
|
+
# runs `bundle update`. Changing one still rewrites the OVERRIDES
|
|
1306
|
+
# section (see #converge_overrides).
|
|
1155
1307
|
next unless override.target.is_a?(String) && override.field == :version
|
|
1156
1308
|
|
|
1157
1309
|
name = override.target
|
|
@@ -1266,7 +1418,7 @@ module Bundler
|
|
|
1266
1418
|
def preload_git_source_worker
|
|
1267
1419
|
workers = Bundler.settings.installation_parallelization
|
|
1268
1420
|
|
|
1269
|
-
@preload_git_source_worker ||= Bundler::Worker.new(workers, "Git source preloading", ->(
|
|
1421
|
+
@preload_git_source_worker ||= Bundler::Worker.new(workers, "Git source preloading", ->(sources, _) { sources.each(&:specs) })
|
|
1270
1422
|
end
|
|
1271
1423
|
|
|
1272
1424
|
def preload_git_sources
|
|
@@ -1277,7 +1429,13 @@ module Bundler
|
|
|
1277
1429
|
end
|
|
1278
1430
|
|
|
1279
1431
|
begin
|
|
1280
|
-
|
|
1432
|
+
# Sources from the same repository share one cache directory, and
|
|
1433
|
+
# running git in that directory from two workers at once makes the
|
|
1434
|
+
# fetches collide. Preload sources that share a cache in one job, one
|
|
1435
|
+
# after the other, and run the separate caches in parallel.
|
|
1436
|
+
needed_git_sources.group_by(&:cache_path).each_value do |sources|
|
|
1437
|
+
preload_git_source_worker.enq(sources)
|
|
1438
|
+
end
|
|
1281
1439
|
ensure
|
|
1282
1440
|
preload_git_source_worker.stop
|
|
1283
1441
|
end
|
data/lib/bundler/dsl.rb
CHANGED
|
@@ -81,11 +81,15 @@ module Bundler
|
|
|
81
81
|
@gemspecs << spec
|
|
82
82
|
|
|
83
83
|
path path, "glob" => glob, "name" => spec.name, "gemspec" => spec do
|
|
84
|
-
|
|
84
|
+
options = {}
|
|
85
|
+
normalize_options(spec.name, [], options)
|
|
86
|
+
add_dependency spec.name, nil, options
|
|
85
87
|
end
|
|
86
88
|
|
|
87
89
|
spec.development_dependencies.each do |dep|
|
|
88
|
-
|
|
90
|
+
options = {}
|
|
91
|
+
normalize_options(dep.name, dep.requirement.as_list, options)
|
|
92
|
+
add_dependency dep.name, dep.requirement.as_list, options.merge("gemspec_dev_dep" => true, "group" => development_group)
|
|
89
93
|
end
|
|
90
94
|
when 0
|
|
91
95
|
raise InvalidOption, "There are no gemspecs at #{expanded_path}"
|
|
@@ -202,7 +206,12 @@ module Bundler
|
|
|
202
206
|
validate_override_target!(target)
|
|
203
207
|
source_location = caller_locations(1, 1)&.first
|
|
204
208
|
|
|
205
|
-
|
|
209
|
+
# 4.1.0.beta2 spelled `with:` and `in:` as `to:` and `from:`.
|
|
210
|
+
if operations.key?(:from)
|
|
211
|
+
raise ArgumentError, "`from:` and `to:` of `override` are now `in:` and `with:`; write `override #{target.inspect}, with: #{operations.fetch(:to, "<gem>").inspect}, in: #{operations[:from].inspect}`"
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
if operations.key?(:in) || operations.key?(:with)
|
|
206
215
|
add_dependency_override(target, operations, source_location)
|
|
207
216
|
return
|
|
208
217
|
end
|
|
@@ -292,8 +301,16 @@ module Bundler
|
|
|
292
301
|
|
|
293
302
|
def validate_override_target!(target)
|
|
294
303
|
return if target == :all
|
|
295
|
-
|
|
296
|
-
|
|
304
|
+
raise ArgumentError, "override target must be :all or a gem name string, got #{target.inspect}" unless target.is_a?(String)
|
|
305
|
+
validate_override_gem_name!(target)
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# Override names are recorded in the lockfile's OVERRIDES section, so they
|
|
309
|
+
# must be valid gem names.
|
|
310
|
+
def validate_override_gem_name!(name)
|
|
311
|
+
validate_gem_name!(name)
|
|
312
|
+
return if Gem::Specification::VALID_NAME_PATTERN.match?(name)
|
|
313
|
+
raise GemfileError, "#{name.inspect} is not a valid gem name"
|
|
297
314
|
end
|
|
298
315
|
|
|
299
316
|
def validate_override_field!(field)
|
|
@@ -324,40 +341,40 @@ module Bundler
|
|
|
324
341
|
end
|
|
325
342
|
|
|
326
343
|
def add_dependency_override(target, operations, source_location)
|
|
327
|
-
unless operations.key?(:
|
|
328
|
-
raise ArgumentError, "`override #{target.inspect},
|
|
344
|
+
unless operations.key?(:in)
|
|
345
|
+
raise ArgumentError, "`override #{target.inspect}, with:` requires `in:` naming the gem whose dependency is rewritten"
|
|
329
346
|
end
|
|
330
|
-
unless operations.key?(:
|
|
331
|
-
raise ArgumentError, "`override #{target.inspect},
|
|
347
|
+
unless operations.key?(:with)
|
|
348
|
+
raise ArgumentError, "`override #{target.inspect}, in:` requires `with:`; use `with: nil` to drop the dependency or `with: \"<gem>\"` to replace it"
|
|
332
349
|
end
|
|
333
350
|
|
|
334
|
-
from = operations[:
|
|
335
|
-
|
|
351
|
+
from = operations[:in]
|
|
352
|
+
with = operations[:with]
|
|
336
353
|
requirement = operations[:version]
|
|
337
354
|
|
|
338
|
-
raise ArgumentError, "`override :all` does not accept `
|
|
339
|
-
raise ArgumentError, "`
|
|
340
|
-
raise ArgumentError, "`
|
|
341
|
-
raise ArgumentError, "`
|
|
342
|
-
|
|
343
|
-
|
|
355
|
+
raise ArgumentError, "`override :all` does not accept `in:`" if target == :all
|
|
356
|
+
raise ArgumentError, "`in:` must be a gem name string, got #{from.inspect}" unless from.is_a?(String)
|
|
357
|
+
raise ArgumentError, "`with:` must be a gem name string or nil, got #{with.inspect}" unless with.nil? || with.is_a?(String)
|
|
358
|
+
raise ArgumentError, "`with:` must name a gem other than #{target.inspect} and #{from.inspect}" if with == target || with == from
|
|
359
|
+
validate_override_gem_name!(from)
|
|
360
|
+
validate_override_gem_name!(with) if with
|
|
344
361
|
|
|
345
|
-
unsupported = operations.keys - [:
|
|
362
|
+
unsupported = operations.keys - [:in, :with, :version]
|
|
346
363
|
if unsupported.any?
|
|
347
|
-
raise ArgumentError, "unsupported override field `#{unsupported.first}:` with `
|
|
364
|
+
raise ArgumentError, "unsupported override field `#{unsupported.first}:` with `in:`; supported fields: `with:`, `version:`"
|
|
348
365
|
end
|
|
349
366
|
|
|
350
367
|
if operations.key?(:version)
|
|
351
|
-
raise ArgumentError, "`version:` with `
|
|
352
|
-
raise ArgumentError, "`version:` with `
|
|
368
|
+
raise ArgumentError, "`version:` with `in:` requires `with:` to name a replacement gem" if with.nil?
|
|
369
|
+
raise ArgumentError, "`version:` with `in:` must be a version requirement string, got #{requirement.inspect}" unless requirement.is_a?(String)
|
|
353
370
|
validate_override_operation!(requirement)
|
|
354
371
|
end
|
|
355
372
|
|
|
356
373
|
if @overrides.any? {|o| o.target == target && o.from == from }
|
|
357
|
-
raise ArgumentError, "duplicate override for #{target.inspect} `
|
|
374
|
+
raise ArgumentError, "duplicate override for #{target.inspect} `in: #{from.inspect}`"
|
|
358
375
|
end
|
|
359
376
|
|
|
360
|
-
@overrides << Override.new(target, :
|
|
377
|
+
@overrides << Override.new(target, :with, with, from: from, requirement: requirement, source_location: source_location)
|
|
361
378
|
end
|
|
362
379
|
|
|
363
380
|
# Dropping a gem the Gemfile requires directly would leave it installed
|
data/lib/bundler/errors.rb
CHANGED
|
@@ -303,4 +303,12 @@ module Bundler
|
|
|
303
303
|
|
|
304
304
|
status_code(41)
|
|
305
305
|
end
|
|
306
|
+
|
|
307
|
+
class CleanError < BundlerError
|
|
308
|
+
def initialize(errors)
|
|
309
|
+
super("Bundler could not remove some unused files:\n\n#{errors.map(&:message).uniq.join("\n")}")
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
status_code(44)
|
|
313
|
+
end
|
|
306
314
|
end
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "rubygems/text"
|
|
4
|
+
|
|
3
5
|
module Bundler
|
|
4
6
|
class Fetcher
|
|
5
7
|
class Downloader
|
|
8
|
+
include Gem::Text
|
|
9
|
+
|
|
6
10
|
HTTP_NON_RETRYABLE_ERRORS = [
|
|
7
11
|
SocketError,
|
|
8
12
|
Errno::EADDRNOTAVAIL,
|
|
@@ -66,13 +70,15 @@ module Bundler
|
|
|
66
70
|
end
|
|
67
71
|
fetch(new_uri, headers, counter + 1)
|
|
68
72
|
when Gem::Net::HTTPRequestedRangeNotSatisfiable
|
|
73
|
+
raise bad_response(response) unless headers.key?("Range")
|
|
74
|
+
|
|
69
75
|
new_headers = headers.dup
|
|
70
76
|
new_headers.delete("Range")
|
|
71
77
|
fetch(uri, new_headers)
|
|
72
78
|
when Gem::Net::HTTPRequestEntityTooLarge
|
|
73
|
-
raise FallbackError, response.body
|
|
79
|
+
raise FallbackError, clean_text(response.body)
|
|
74
80
|
when Gem::Net::HTTPTooManyRequests
|
|
75
|
-
raise TooManyRequestsError, response.body
|
|
81
|
+
raise TooManyRequestsError, clean_text(response.body)
|
|
76
82
|
when Gem::Net::HTTPUnauthorized
|
|
77
83
|
raise BadAuthenticationError, uri.host if uri.userinfo
|
|
78
84
|
raise AuthenticationRequiredError, uri.host
|
|
@@ -81,9 +87,7 @@ module Bundler
|
|
|
81
87
|
when Gem::Net::HTTPNotFound
|
|
82
88
|
raise FallbackError, "Gem::Net::HTTPNotFound: #{filtered_uri}"
|
|
83
89
|
else
|
|
84
|
-
|
|
85
|
-
message += ": #{response.body}" unless response.body.empty?
|
|
86
|
-
raise HTTPError, message
|
|
90
|
+
raise bad_response(response)
|
|
87
91
|
end
|
|
88
92
|
end
|
|
89
93
|
|
|
@@ -121,6 +125,12 @@ module Bundler
|
|
|
121
125
|
|
|
122
126
|
private
|
|
123
127
|
|
|
128
|
+
def bad_response(response)
|
|
129
|
+
message = "Gem::#{response.class.name.gsub(/\AGem::/, "")}"
|
|
130
|
+
message += ": #{clean_text(response.body)}" unless response.body.empty?
|
|
131
|
+
HTTPError.new(message)
|
|
132
|
+
end
|
|
133
|
+
|
|
124
134
|
def network_down_error(uri, filtered_uri)
|
|
125
135
|
host = uri.host
|
|
126
136
|
host_port = "#{host}:#{uri.port}"
|
data/lib/bundler/fetcher.rb
CHANGED
|
@@ -157,7 +157,10 @@ module Bundler
|
|
|
157
157
|
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
|
|
158
158
|
Bundler.load_gemspec(cached_spec_path)
|
|
159
159
|
else
|
|
160
|
-
|
|
160
|
+
body = Bundler::Retry.new("fetcher", FAIL_ERRORS).attempts do
|
|
161
|
+
downloader.fetch(uri).body
|
|
162
|
+
end
|
|
163
|
+
Bundler.safe_load_marshal Bundler.rubygems.inflate(body)
|
|
161
164
|
end
|
|
162
165
|
raise MarshalError, "is #{spec.inspect}" unless spec.is_a?(Gem::Specification)
|
|
163
166
|
spec
|
data/lib/bundler/index.rb
CHANGED
|
@@ -188,8 +188,13 @@ module Bundler
|
|
|
188
188
|
EMPTY_SEARCH = [].freeze
|
|
189
189
|
|
|
190
190
|
def search_by_spec(spec)
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
specs_by_name = @specs[spec.name]
|
|
192
|
+
return EMPTY_SEARCH unless specs_by_name
|
|
193
|
+
|
|
194
|
+
full_names = [spec.full_name]
|
|
195
|
+
full_names.concat(spec.content_addressed_full_names) if spec.is_a?(LazySpecification)
|
|
196
|
+
|
|
197
|
+
full_names.filter_map {|full_name| specs_by_name[full_name] }
|
|
193
198
|
end
|
|
194
199
|
|
|
195
200
|
def find_by_spec(spec)
|
data/lib/bundler/inline.rb
CHANGED
|
@@ -72,18 +72,25 @@ def gemfile(force_latest_compatible = false, options = {}, &gemfile)
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
# When possible we do the install in a subprocess because to install
|
|
75
|
-
# gems we need to require some default gems like `
|
|
75
|
+
# gems we need to require some default gems like `tempfile` etc
|
|
76
76
|
# which may later conflict with the Gemfile requirements.
|
|
77
77
|
installed_in_fork = false
|
|
78
78
|
if Process.respond_to?(:fork)
|
|
79
79
|
Gem.load_yaml # Avoid NameError on Ruby 3.2's safe_yaml.rb after Gem::Specification.reset
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
# exit! leaves the script's at_exit hooks to this process, which installs again on failure to raise the error here
|
|
81
|
+
pid = Process.fork do
|
|
82
|
+
$VERBOSE = nil
|
|
83
|
+
do_install.call
|
|
84
|
+
$stdout.flush
|
|
85
|
+
$stderr.flush
|
|
86
|
+
exit!(true)
|
|
87
|
+
rescue Exception # rubocop:disable Lint/RescueException
|
|
88
|
+
exit!(false)
|
|
89
|
+
end
|
|
90
|
+
installed_in_fork = Process.waitpid2(pid).last.success?
|
|
91
|
+
end
|
|
86
92
|
|
|
93
|
+
if installed_in_fork
|
|
87
94
|
Bundler.reset!
|
|
88
95
|
Gem::Specification.reset
|
|
89
96
|
Bundler.instance_variable_set(:@bundle_path, Pathname.new(Gem.dir))
|
|
@@ -110,7 +117,8 @@ def gemfile(force_latest_compatible = false, options = {}, &gemfile)
|
|
|
110
117
|
configure_forked_definition.call(definition) if installed_in_fork
|
|
111
118
|
|
|
112
119
|
begin
|
|
113
|
-
runtime = Bundler::Runtime.new(nil, definition)
|
|
120
|
+
runtime = Bundler::Runtime.new(nil, definition)
|
|
121
|
+
installed_in_fork ? Bundler.ui.silence { runtime.setup } : runtime.setup
|
|
114
122
|
rescue Gem::LoadError => e
|
|
115
123
|
name = e.name
|
|
116
124
|
version = e.requirement.requirements.first[1]
|
data/lib/bundler/installer.rb
CHANGED
|
@@ -80,6 +80,7 @@ module Bundler
|
|
|
80
80
|
ensure_specs_are_compatible!
|
|
81
81
|
load_plugins
|
|
82
82
|
end
|
|
83
|
+
warn_on_default_gem_downgrades
|
|
83
84
|
install(options)
|
|
84
85
|
|
|
85
86
|
Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available
|
|
@@ -258,6 +259,24 @@ module Bundler
|
|
|
258
259
|
"to add it to the lockfile as a fallback, then commit the updated #{SharedHelpers.relative_lockfile_path}."
|
|
259
260
|
end
|
|
260
261
|
|
|
262
|
+
def warn_on_default_gem_downgrades
|
|
263
|
+
default_gems = Bundler.rubygems.default_stubs.to_h {|spec| [spec.name, spec] }
|
|
264
|
+
downgrades = @definition.specs.sort_by(&:name).filter_map do |spec|
|
|
265
|
+
# The specs always include the running Bundler, which the Gemfile does not choose.
|
|
266
|
+
next if spec.name == "bundler"
|
|
267
|
+
default_spec = default_gems[spec.name]
|
|
268
|
+
next unless default_spec && spec.version < default_spec.version
|
|
269
|
+
[spec, default_spec]
|
|
270
|
+
end
|
|
271
|
+
return if downgrades.empty?
|
|
272
|
+
|
|
273
|
+
message = "Your bundle downgrades the following default gems shipped with #{Bundler::RubyVersion.system}:\n"
|
|
274
|
+
downgrades.each do |spec, default_spec|
|
|
275
|
+
message += " * #{spec.name} #{spec.version} (default: #{default_spec.version})\n"
|
|
276
|
+
end
|
|
277
|
+
Bundler.ui.warn message.chomp
|
|
278
|
+
end
|
|
279
|
+
|
|
261
280
|
def lock
|
|
262
281
|
@definition.lock
|
|
263
282
|
end
|