bundler 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/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/compact_index_client/http_fetcher.rb +3 -1
- data/lib/rubygems/compact_index_client/parser.rb +1 -0
- 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
- metadata +2 -2
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
|
|
@@ -8,7 +8,7 @@ module Bundler
|
|
|
8
8
|
include MatchPlatform
|
|
9
9
|
include ForcePlatform
|
|
10
10
|
|
|
11
|
-
attr_reader :name, :version, :platform, :materialization, :
|
|
11
|
+
attr_reader :name, :version, :platform, :materialization, :content_addresses
|
|
12
12
|
attr_accessor :source, :remote, :force_ruby_platform, :dependencies, :required_ruby_version, :required_rubygems_version
|
|
13
13
|
attr_accessor :overrides
|
|
14
14
|
|
|
@@ -27,7 +27,14 @@ module Bundler
|
|
|
27
27
|
alias_method :runtime_dependencies, :dependencies
|
|
28
28
|
|
|
29
29
|
def self.from_spec(s)
|
|
30
|
-
|
|
30
|
+
content_addresses = if s.is_a?(LazySpecification)
|
|
31
|
+
s.content_addresses
|
|
32
|
+
elsif s.content_address
|
|
33
|
+
{ s.content_address => Gem::ContentAddress.ruby_abi_for(s.required_ruby_version) }
|
|
34
|
+
else
|
|
35
|
+
{}
|
|
36
|
+
end
|
|
37
|
+
lazy_spec = new(s.name, s.version, s.platform, s.source, content_addresses: content_addresses)
|
|
31
38
|
lazy_spec.dependencies = s.runtime_dependencies
|
|
32
39
|
lazy_spec.required_ruby_version = s.required_ruby_version
|
|
33
40
|
lazy_spec.required_rubygems_version = s.required_rubygems_version
|
|
@@ -35,14 +42,14 @@ module Bundler
|
|
|
35
42
|
lazy_spec
|
|
36
43
|
end
|
|
37
44
|
|
|
38
|
-
def initialize(name, version, platform, source = nil,
|
|
45
|
+
def initialize(name, version, platform, source = nil, content_addresses: {}, **materialization_options)
|
|
39
46
|
@name = name
|
|
40
47
|
@version = version
|
|
41
48
|
@dependencies = []
|
|
42
49
|
@required_ruby_version = Gem::Requirement.default
|
|
43
50
|
@required_rubygems_version = Gem::Requirement.default
|
|
44
51
|
@platform = platform || Gem::Platform::RUBY
|
|
45
|
-
|
|
52
|
+
self.content_addresses = content_addresses
|
|
46
53
|
|
|
47
54
|
@original_source = source
|
|
48
55
|
@source = source
|
|
@@ -53,6 +60,14 @@ module Bundler
|
|
|
53
60
|
@materialization = nil
|
|
54
61
|
end
|
|
55
62
|
|
|
63
|
+
def content_addresses=(addresses)
|
|
64
|
+
@content_addresses = addresses.sort_by {|address, ruby_abi| [ruby_abi.to_s, address] }.to_h
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def content_addressed_full_names
|
|
68
|
+
@content_addresses.keys.map {|address| "#{@name}-#{@version}-#{address}" }
|
|
69
|
+
end
|
|
70
|
+
|
|
56
71
|
def missing?
|
|
57
72
|
@materialization == self
|
|
58
73
|
end
|
|
@@ -66,9 +81,7 @@ module Bundler
|
|
|
66
81
|
end
|
|
67
82
|
|
|
68
83
|
def full_name
|
|
69
|
-
@full_name ||= if Gem::
|
|
70
|
-
"#{@name}-#{@version}-#{@content_address}"
|
|
71
|
-
elsif platform == Gem::Platform::RUBY
|
|
84
|
+
@full_name ||= if platform == Gem::Platform::RUBY
|
|
72
85
|
"#{@name}-#{@version}"
|
|
73
86
|
else
|
|
74
87
|
"#{@name}-#{@version}-#{platform}"
|
|
@@ -84,7 +97,7 @@ module Bundler
|
|
|
84
97
|
end
|
|
85
98
|
|
|
86
99
|
def name_tuple
|
|
87
|
-
Gem::NameTuple.new(@name, @version, @platform
|
|
100
|
+
Gem::NameTuple.new(@name, @version, @platform)
|
|
88
101
|
end
|
|
89
102
|
|
|
90
103
|
def ==(other)
|
|
@@ -119,16 +132,6 @@ module Bundler
|
|
|
119
132
|
@name == dependency.name && effective_requirement.satisfied_by?(Gem::Version.new(@version))
|
|
120
133
|
end
|
|
121
134
|
|
|
122
|
-
##
|
|
123
|
-
# Assigns the content address parsed from the lockfile's CONTENT
|
|
124
|
-
# ADDRESSES section. The full name embeds the content address, so its
|
|
125
|
-
# memoization must be invalidated.
|
|
126
|
-
|
|
127
|
-
def content_address=(value)
|
|
128
|
-
@content_address = value
|
|
129
|
-
@full_name = nil
|
|
130
|
-
end
|
|
131
|
-
|
|
132
135
|
def to_lock
|
|
133
136
|
out = String.new
|
|
134
137
|
out << " #{lock_name}\n"
|
|
@@ -141,10 +144,12 @@ module Bundler
|
|
|
141
144
|
out
|
|
142
145
|
end
|
|
143
146
|
|
|
147
|
+
# Every gem this row may install: the platform gem and each content-addressed
|
|
148
|
+
# gem it lists, so a cache serves all the Rubies the lockfile covers.
|
|
144
149
|
def materialize_for_cache
|
|
145
150
|
source.remote!
|
|
146
151
|
|
|
147
|
-
materialize(self
|
|
152
|
+
Array(materialize(self) {|specs| specs })
|
|
148
153
|
end
|
|
149
154
|
|
|
150
155
|
def materialized_for_installation(locked_platforms = nil)
|
|
@@ -157,7 +162,7 @@ module Bundler
|
|
|
157
162
|
source.local!
|
|
158
163
|
|
|
159
164
|
if use_exact_resolved_specifications?
|
|
160
|
-
spec = materialize(self) {|specs| choose_compatible(specs, fallback_to_non_installable: false) }
|
|
165
|
+
spec = materialize(self, content_addressed_only: content_address_locked_for_running_ruby?) {|specs| choose_compatible(specs, fallback_to_non_installable: false) }
|
|
161
166
|
return spec if spec
|
|
162
167
|
|
|
163
168
|
# Exact spec is incompatible; in frozen mode, try to find a compatible platform variant
|
|
@@ -205,7 +210,7 @@ module Bundler
|
|
|
205
210
|
# Used for legacy lockfiles and as a fallback when the exact locked spec
|
|
206
211
|
# is incompatible. Falls back to frozen bundle behavior if none match.
|
|
207
212
|
def resolve_best_platform(specs, locked_platforms: nil)
|
|
208
|
-
specs = MatchPlatform.select_all_content_address_match(specs,
|
|
213
|
+
specs = MatchPlatform.select_all_content_address_match(specs, content_addresses)
|
|
209
214
|
|
|
210
215
|
find_compatible_platform_spec(specs, locked_platforms: locked_platforms) || frozen_bundle_fallback(specs)
|
|
211
216
|
end
|
|
@@ -213,7 +218,7 @@ module Bundler
|
|
|
213
218
|
def find_compatible_platform_spec(specs, locked_platforms: nil)
|
|
214
219
|
candidate_platforms(locked_platforms: locked_platforms).each do |plat|
|
|
215
220
|
candidates = MatchPlatform.select_best_platform_match(specs, plat)
|
|
216
|
-
spec = choose_compatible(candidates, fallback_to_non_installable: false)
|
|
221
|
+
spec = choose_compatible(candidates, fallback_to_non_installable: false, locked_platforms: locked_platforms)
|
|
217
222
|
return spec if spec
|
|
218
223
|
end
|
|
219
224
|
nil
|
|
@@ -247,8 +252,16 @@ module Bundler
|
|
|
247
252
|
(most_specific_locked_platform != generic_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
|
|
248
253
|
end
|
|
249
254
|
|
|
250
|
-
|
|
255
|
+
# Once the lockfile pins the running Ruby's content-addressed gem, the
|
|
256
|
+
# platform gem an earlier frozen fallback installed no longer satisfies the
|
|
257
|
+
# row, so the pinned gem gets installed instead.
|
|
258
|
+
def content_address_locked_for_running_ruby?
|
|
259
|
+
Gem::ContentAddress.platform_eligible?(platform) && content_addresses.value?(Gem.ruby_abi)
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def materialize(query, content_addressed_only: false)
|
|
251
263
|
matching_specs = source.specs.search(query)
|
|
264
|
+
matching_specs = matching_specs.select {|spec| Gem::ContentAddress.content_addressed?(spec, validate_ruby_abi: false) } if content_addressed_only
|
|
252
265
|
return self if matching_specs.empty?
|
|
253
266
|
|
|
254
267
|
yield matching_specs
|
|
@@ -259,7 +272,7 @@ module Bundler
|
|
|
259
272
|
# lockfile, which is not allowed. In that case, we will give a proper error
|
|
260
273
|
# about the mismatch higher up the stack, right before trying to install the
|
|
261
274
|
# bad gem.
|
|
262
|
-
def choose_compatible(candidates, fallback_to_non_installable: Bundler.frozen_bundle
|
|
275
|
+
def choose_compatible(candidates, fallback_to_non_installable: Bundler.frozen_bundle?, locked_platforms: nil)
|
|
263
276
|
override_list = overrides || []
|
|
264
277
|
search = candidates.reverse.find do |spec|
|
|
265
278
|
spec.is_a?(StubSpecification) || spec.matches_current_metadata_with_overrides?(override_list)
|
|
@@ -271,7 +284,11 @@ module Bundler
|
|
|
271
284
|
if search
|
|
272
285
|
validate_dependencies(search) if search.platform == platform
|
|
273
286
|
|
|
274
|
-
|
|
287
|
+
if search.instance_of?(RemoteSpecification) || search.instance_of?(EndpointSpecification)
|
|
288
|
+
# A frozen fallback onto a variant the lockfile locks too, like the
|
|
289
|
+
# ruby gem, installs a locked gem rather than an insecure one.
|
|
290
|
+
search.locked_platform = locked_platforms&.include?(search.platform) ? search.platform : platform
|
|
291
|
+
end
|
|
275
292
|
end
|
|
276
293
|
search
|
|
277
294
|
end
|
|
@@ -19,8 +19,10 @@ module Bundler
|
|
|
19
19
|
add_sources
|
|
20
20
|
add_platforms
|
|
21
21
|
add_dependencies
|
|
22
|
+
add_overrides
|
|
22
23
|
add_content_addresses
|
|
23
24
|
add_checksums
|
|
25
|
+
add_ruby_abis
|
|
24
26
|
add_locked_ruby_version
|
|
25
27
|
add_bundled_with
|
|
26
28
|
|
|
@@ -67,18 +69,26 @@ module Bundler
|
|
|
67
69
|
end
|
|
68
70
|
end
|
|
69
71
|
|
|
72
|
+
def add_overrides
|
|
73
|
+
overrides = definition.overrides_to_lock
|
|
74
|
+
add_section("OVERRIDES", overrides) unless overrides.empty?
|
|
75
|
+
end
|
|
76
|
+
|
|
70
77
|
def add_content_addresses
|
|
71
|
-
content_addresses = definition.resolve.
|
|
72
|
-
next
|
|
78
|
+
content_addresses = definition.resolve.flat_map do |spec|
|
|
79
|
+
next [] if spec.platform == Gem::Platform::RUBY
|
|
73
80
|
|
|
74
|
-
|
|
81
|
+
spec.content_addresses.zip(spec.content_addressed_full_names).map do |(content_address, ruby_abi), full_name|
|
|
82
|
+
line = "#{spec.lock_name} #{content_address}"
|
|
83
|
+
line += " abi=#{ruby_abi}" if ruby_abi
|
|
75
84
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
if definition.locked_checksums
|
|
86
|
+
checksums = spec.source.checksum_store.checksums_to_lock(full_name)
|
|
87
|
+
line += " #{checksums}" if checksums
|
|
88
|
+
end
|
|
80
89
|
|
|
81
|
-
|
|
90
|
+
line
|
|
91
|
+
end
|
|
82
92
|
end
|
|
83
93
|
|
|
84
94
|
add_section("CONTENT ADDRESSES", content_addresses) unless content_addresses.empty?
|
|
@@ -89,7 +99,7 @@ module Bundler
|
|
|
89
99
|
checksums = definition.resolve.filter_map do |spec|
|
|
90
100
|
line = spec.source.checksum_store.to_lock(spec)
|
|
91
101
|
|
|
92
|
-
next if line == spec.lock_name &&
|
|
102
|
+
next if line == spec.lock_name && spec.content_addresses.any?
|
|
93
103
|
|
|
94
104
|
line
|
|
95
105
|
end
|
|
@@ -97,6 +107,14 @@ module Bundler
|
|
|
97
107
|
add_section("CHECKSUMS", checksums + bundler_checksum)
|
|
98
108
|
end
|
|
99
109
|
|
|
110
|
+
def add_ruby_abis
|
|
111
|
+
ruby_abis = definition.ruby_abis
|
|
112
|
+
return if ruby_abis.empty? || definition.resolve.none? {|spec| spec.content_addresses.any? }
|
|
113
|
+
|
|
114
|
+
out << "\nRUBY ABIS\n"
|
|
115
|
+
ruby_abis.each {|ruby_abi| out << " #{ruby_abi}\n" }
|
|
116
|
+
end
|
|
117
|
+
|
|
100
118
|
def add_locked_ruby_version
|
|
101
119
|
return unless locked_ruby_version = definition.locked_ruby_version
|
|
102
120
|
add_section("RUBY VERSION", locked_ruby_version.to_s)
|
|
@@ -36,14 +36,18 @@ module Bundler
|
|
|
36
36
|
:bundler_version,
|
|
37
37
|
:ruby_version,
|
|
38
38
|
:checksums,
|
|
39
|
+
:overrides,
|
|
40
|
+
:ruby_abis,
|
|
39
41
|
)
|
|
40
42
|
|
|
41
43
|
BUNDLED = "BUNDLED WITH"
|
|
42
44
|
DEPENDENCIES = "DEPENDENCIES"
|
|
43
45
|
CHECKSUMS = "CHECKSUMS"
|
|
44
46
|
CONTENT_ADDRESSES = "CONTENT ADDRESSES"
|
|
47
|
+
OVERRIDES = "OVERRIDES"
|
|
45
48
|
PLATFORMS = "PLATFORMS"
|
|
46
49
|
RUBY = "RUBY VERSION"
|
|
50
|
+
RUBY_ABIS = "RUBY ABIS"
|
|
47
51
|
GIT = "GIT"
|
|
48
52
|
GEM = "GEM"
|
|
49
53
|
PATH = "PATH"
|
|
@@ -58,10 +62,14 @@ module Bundler
|
|
|
58
62
|
Gem::Version.create("1.12") => [RUBY].freeze,
|
|
59
63
|
Gem::Version.create("1.13") => [PLUGIN].freeze,
|
|
60
64
|
Gem::Version.create("2.5.0") => [CHECKSUMS].freeze,
|
|
61
|
-
Gem::Version.create("4.1.0") => [CONTENT_ADDRESSES].freeze,
|
|
65
|
+
Gem::Version.create("4.1.0") => [CONTENT_ADDRESSES, RUBY_ABIS].freeze,
|
|
62
66
|
}.freeze
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
# OVERRIDES is deliberately not in SECTIONS_BY_VERSION_INTRODUCED. Sections
|
|
69
|
+
# listed there are ignored when comparing a lockfile bundled with an older
|
|
70
|
+
# Bundler, so a lockfile still BUNDLED WITH 4.0 would never get its
|
|
71
|
+
# overrides recorded while the resolution stays the same.
|
|
72
|
+
KNOWN_SECTIONS = (SECTIONS_BY_VERSION_INTRODUCED.values.flatten + [OVERRIDES]).freeze
|
|
65
73
|
|
|
66
74
|
ENVIRONMENT_VERSION_SECTIONS = [BUNDLED, RUBY].freeze
|
|
67
75
|
deprecate_constant(:ENVIRONMENT_VERSION_SECTIONS)
|
|
@@ -101,9 +109,11 @@ module Bundler
|
|
|
101
109
|
@platforms = []
|
|
102
110
|
@sources = []
|
|
103
111
|
@metadata_source = Source::Metadata.new
|
|
112
|
+
@ruby_abis = []
|
|
104
113
|
@dependencies = {}
|
|
105
114
|
@parse_method = nil
|
|
106
115
|
@specs = {}
|
|
116
|
+
@overrides = nil
|
|
107
117
|
@lockfile_path = lockfile_path || begin
|
|
108
118
|
SharedHelpers.relative_lockfile_path
|
|
109
119
|
rescue GemfileNotFound
|
|
@@ -111,6 +121,7 @@ module Bundler
|
|
|
111
121
|
end
|
|
112
122
|
@pos = Position.new(1, 1)
|
|
113
123
|
@strict = strict
|
|
124
|
+
@spec_names_by_source = {}.compare_by_identity
|
|
114
125
|
|
|
115
126
|
if lockfile.match?(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
|
|
116
127
|
raise LockfileError, "Your #{@lockfile_path} contains merge conflicts.\n" \
|
|
@@ -144,10 +155,15 @@ module Bundler
|
|
|
144
155
|
@parse_method = :parse_checksum
|
|
145
156
|
elsif line == CONTENT_ADDRESSES
|
|
146
157
|
@parse_method = :parse_content_address
|
|
158
|
+
elsif line == OVERRIDES
|
|
159
|
+
@overrides = []
|
|
160
|
+
@parse_method = :parse_override
|
|
147
161
|
elsif line == PLATFORMS
|
|
148
162
|
@parse_method = :parse_platform
|
|
149
163
|
elsif line == RUBY
|
|
150
164
|
@parse_method = :parse_ruby
|
|
165
|
+
elsif line == RUBY_ABIS
|
|
166
|
+
@parse_method = :parse_ruby_abi
|
|
151
167
|
elsif line == BUNDLED
|
|
152
168
|
@parse_method = :parse_bundled_with
|
|
153
169
|
elsif /^[^\s]/.match?(line)
|
|
@@ -158,6 +174,8 @@ module Bundler
|
|
|
158
174
|
@pos.advance!(line)
|
|
159
175
|
end
|
|
160
176
|
|
|
177
|
+
@spec_names_by_source.each {|source, names| source.add_dependency_names(names) }
|
|
178
|
+
|
|
161
179
|
if @platforms.include?(Gem::Platform::X64_MINGW_LEGACY)
|
|
162
180
|
SharedHelpers.feature_deprecated!("Found x64-mingw32 in lockfile, which is deprecated and will be removed in the future.")
|
|
163
181
|
end
|
|
@@ -237,6 +255,7 @@ module Bundler
|
|
|
237
255
|
#{space}\(([^-]*) # Space, followed by version
|
|
238
256
|
-(.*)\) # Platform, always present for content-addressable gems
|
|
239
257
|
#{space}([0-9a-f]{8,64}) # Content address
|
|
258
|
+
(?:#{space}abi=(\d+\.\d+))? # Optional Ruby ABI the gem is built for
|
|
240
259
|
(?:#{space}([^ ]+))? # Optional checksums
|
|
241
260
|
$ # Line end
|
|
242
261
|
/xo
|
|
@@ -270,6 +289,12 @@ module Bundler
|
|
|
270
289
|
@dependencies[dep.name] = dep
|
|
271
290
|
end
|
|
272
291
|
|
|
292
|
+
def parse_override(line)
|
|
293
|
+
raise ArgumentError, "invalid override in lockfile: #{line.inspect}" unless line.start_with?(" ") && line[2] != " "
|
|
294
|
+
|
|
295
|
+
@overrides << Override.from_lock(line[2..])
|
|
296
|
+
end
|
|
297
|
+
|
|
273
298
|
def parse_checksum(line)
|
|
274
299
|
return unless line =~ NAME_VERSION
|
|
275
300
|
|
|
@@ -309,19 +334,21 @@ module Bundler
|
|
|
309
334
|
version = Gem::Version.new($2)
|
|
310
335
|
platform = Gem::Platform.new($3)
|
|
311
336
|
content_address = $4
|
|
312
|
-
|
|
337
|
+
ruby_abi = $5
|
|
338
|
+
checksums = $6
|
|
313
339
|
|
|
314
340
|
spec = @specs[Gem::NameTuple.new(name, version, platform).full_name]
|
|
315
341
|
return unless spec
|
|
316
342
|
|
|
317
|
-
spec.
|
|
343
|
+
spec.content_addresses = spec.content_addresses.merge(content_address => ruby_abi)
|
|
318
344
|
|
|
319
345
|
return unless checksums
|
|
320
346
|
|
|
347
|
+
gem = Gem::NameTuple.new(name, version, platform, content_address: content_address)
|
|
321
348
|
checksums.split(",") do |lock_checksum|
|
|
322
349
|
column = line.index(lock_checksum) + 1
|
|
323
350
|
checksum = Checksum.from_lock(lock_checksum, "#{@lockfile_path}:#{@pos.line}:#{column}")
|
|
324
|
-
spec.source.checksum_store.register(
|
|
351
|
+
spec.source.checksum_store.register(gem, checksum)
|
|
325
352
|
end
|
|
326
353
|
end
|
|
327
354
|
|
|
@@ -338,7 +365,7 @@ module Bundler
|
|
|
338
365
|
version = Gem::Version.new(version)
|
|
339
366
|
platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
|
|
340
367
|
@current_spec = LazySpecification.new(name, version, platform, @current_source, strict: @strict)
|
|
341
|
-
@current_source
|
|
368
|
+
(@spec_names_by_source[@current_source] ||= []) << name
|
|
342
369
|
|
|
343
370
|
@specs[@current_spec.full_name] = @current_spec
|
|
344
371
|
elsif spaces.size == 6
|
|
@@ -352,6 +379,11 @@ module Bundler
|
|
|
352
379
|
@platforms << Gem::Platform.new($1.strip) if line =~ /^ (.*)$/
|
|
353
380
|
end
|
|
354
381
|
|
|
382
|
+
def parse_ruby_abi(line)
|
|
383
|
+
ruby_abi = line.strip
|
|
384
|
+
@ruby_abis << ruby_abi if Gem::ContentAddress.valid_ruby_abi?(ruby_abi)
|
|
385
|
+
end
|
|
386
|
+
|
|
355
387
|
def parse_bundled_with(line)
|
|
356
388
|
line.strip!
|
|
357
389
|
return unless Gem::Version.correct?(line)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
.SH "NAME"
|
|
5
5
|
\fBbundle\-lock\fR \- Creates / Updates a lockfile without installing
|
|
6
6
|
.SH "SYNOPSIS"
|
|
7
|
-
\fBbundle lock\fR [\-\-update] [\-\-bundler[=BUNDLER]] [\-\-local] [\-\-print] [\-\-lockfile=PATH] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-add\-checksums] [\-\-add\-platform] [\-\-remove\-platform] [\-\-normalize\-platforms] [\-\-patch] [\-\-minor] [\-\-major] [\-\-pre] [\-\-strict] [\-\-conservative] [\-\-cooldown=NUMBER]
|
|
7
|
+
\fBbundle lock\fR [\-\-update] [\-\-bundler[=BUNDLER]] [\-\-local] [\-\-print] [\-\-lockfile=PATH] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-add\-checksums] [\-\-add\-platform] [\-\-remove\-platform] [\-\-normalize\-platforms] [\-\-add\-ruby\-abi] [\-\-remove\-ruby\-abi] [\-\-patch] [\-\-minor] [\-\-major] [\-\-pre] [\-\-strict] [\-\-conservative] [\-\-cooldown=NUMBER]
|
|
8
8
|
.SH "DESCRIPTION"
|
|
9
9
|
Lock the gems specified in Gemfile\.
|
|
10
10
|
.SH "OPTIONS"
|
|
@@ -42,6 +42,12 @@ Remove a platform from the lockfile\.
|
|
|
42
42
|
\fB\-\-normalize\-platforms\fR
|
|
43
43
|
Normalize lockfile platforms\.
|
|
44
44
|
.TP
|
|
45
|
+
\fB\-\-add\-ruby\-abi=<list>\fR
|
|
46
|
+
Lock the content\-addressed gems of the bundle for a Ruby ABI (a major and minor version, like \fB3\.4\fR), re\-resolving to record them\. Running \fBbundle install\fR under that Ruby does the same\.
|
|
47
|
+
.TP
|
|
48
|
+
\fB\-\-remove\-ruby\-abi=<list>\fR
|
|
49
|
+
Drop the content\-addressed gems for a Ruby ABI from the lockfile\.
|
|
50
|
+
.TP
|
|
45
51
|
\fB\-\-patch\fR
|
|
46
52
|
If updating, prefer updating only to next patch version\.
|
|
47
53
|
.TP
|
|
@@ -14,6 +14,8 @@ bundle-lock(1) -- Creates / Updates a lockfile without installing
|
|
|
14
14
|
[--add-platform]
|
|
15
15
|
[--remove-platform]
|
|
16
16
|
[--normalize-platforms]
|
|
17
|
+
[--add-ruby-abi]
|
|
18
|
+
[--remove-ruby-abi]
|
|
17
19
|
[--patch]
|
|
18
20
|
[--minor]
|
|
19
21
|
[--major]
|
|
@@ -68,6 +70,14 @@ Lock the gems specified in Gemfile.
|
|
|
68
70
|
* `--normalize-platforms`:
|
|
69
71
|
Normalize lockfile platforms.
|
|
70
72
|
|
|
73
|
+
* `--add-ruby-abi=<list>`:
|
|
74
|
+
Lock the content-addressed gems of the bundle for a Ruby ABI (a
|
|
75
|
+
major and minor version, like `3.4`), re-resolving to record them. Running
|
|
76
|
+
`bundle install` under that Ruby does the same.
|
|
77
|
+
|
|
78
|
+
* `--remove-ruby-abi=<list>`:
|
|
79
|
+
Drop the content-addressed gems for a Ruby ABI from the lockfile.
|
|
80
|
+
|
|
71
81
|
* `--patch`:
|
|
72
82
|
If updating, prefer updating only to next patch version.
|
|
73
83
|
|
|
@@ -69,6 +69,67 @@ No options\.
|
|
|
69
69
|
Describe subcommands or one specific subcommand\.
|
|
70
70
|
.P
|
|
71
71
|
No options\.
|
|
72
|
+
.SH "HOOKS"
|
|
73
|
+
A plugin can run code at defined points of Bundler's work by registering a hook\. In the plugin's \fBplugins\.rb\fR, pass one of the event constants of \fBBundler::Plugin::Events\fR and a block to \fBBundler::Plugin::API\.hook\fR\. Bundler loads a plugin that registers a hook for an event when that event fires, and calls the block with the arguments listed for the event below\.
|
|
74
|
+
.IP "" 4
|
|
75
|
+
.nf
|
|
76
|
+
Bundler::Plugin::API\.hook Bundler::Plugin::Events::GEM_BEFORE_INSTALL_ALL do |dependencies|
|
|
77
|
+
puts "about to install #{dependencies\.map(&:name)\.join(", ")}"
|
|
78
|
+
end
|
|
79
|
+
.fi
|
|
80
|
+
.IP "" 0
|
|
81
|
+
.P
|
|
82
|
+
The events fire in the order listed here\.
|
|
83
|
+
.P
|
|
84
|
+
\fBGEMFILE EVALUATION\fR
|
|
85
|
+
.TP
|
|
86
|
+
\fBGEM_BEFORE_EVAL\fR (\fBbefore\-eval\fR)
|
|
87
|
+
Called before the Gemfile is evaluated, with the path to the Gemfile and the path to the lockfile (\fBnil\fR when there is no lockfile)\.
|
|
88
|
+
.TP
|
|
89
|
+
\fBGEM_AFTER_EVAL\fR (\fBafter\-eval\fR)
|
|
90
|
+
Called after the Gemfile is evaluated, with the resulting \fBBundler::Definition\fR\.
|
|
91
|
+
.P
|
|
92
|
+
\fBINSTALLATION\fR
|
|
93
|
+
.TP
|
|
94
|
+
\fBGEM_BEFORE_INSTALL_ALL\fR (\fBbefore\-install\-all\fR)
|
|
95
|
+
Called before any gem is installed, with an Array of the \fBBundler::Dependency\fR objects declared in the Gemfile\.
|
|
96
|
+
.TP
|
|
97
|
+
\fBGEM_BEFORE_FETCH\fR (\fBbefore\-fetch\fR)
|
|
98
|
+
Called before each individual gem is downloaded from a remote source, with a spec\-like object responding to the \fBGem::Specification\fR API (for example a \fBBundler::EndpointSpecification\fR or \fBBundler::RemoteSpecification\fR)\. Does not fire for a gem that is already present in the download cache\.
|
|
99
|
+
.TP
|
|
100
|
+
\fBGEM_AFTER_FETCH\fR (\fBafter\-fetch\fR)
|
|
101
|
+
Called after each individual gem is downloaded from a remote source, with the same spec\-like object as \fBGEM_BEFORE_FETCH\fR\. Also fires when the download fails\.
|
|
102
|
+
.TP
|
|
103
|
+
\fBGIT_BEFORE_FETCH\fR (\fBbefore\-git\-fetch\fR)
|
|
104
|
+
Called before a git source is fetched or checked out, with the \fBBundler::Source::Git\fR being fetched\.
|
|
105
|
+
.TP
|
|
106
|
+
\fBGIT_AFTER_FETCH\fR (\fBafter\-git\-fetch\fR)
|
|
107
|
+
Called after a git source is fetched or checked out, with the same \fBBundler::Source::Git\fR\. Also fires when the fetch or checkout fails\.
|
|
108
|
+
.TP
|
|
109
|
+
\fBGEM_BEFORE_INSTALL\fR (\fBbefore\-install\fR)
|
|
110
|
+
Called before each individual gem is installed, with a \fBBundler::ParallelInstaller::SpecInstallation\fR\. Its \fBstate\fR, \fBerror\fR and \fBpost_install_message\fR are not set yet, as nothing has been installed\.
|
|
111
|
+
.TP
|
|
112
|
+
\fBGEM_AFTER_INSTALL\fR (\fBafter\-install\fR)
|
|
113
|
+
Called after each individual gem is installed, with the same \fBBundler::ParallelInstaller::SpecInstallation\fR\. If its \fBstate\fR is \fBfailed\fR, \fBerror\fR holds the exception; if the \fBstate\fR is \fBsuccess\fR, a \fBpost_install_message\fR may be present\.
|
|
114
|
+
.TP
|
|
115
|
+
\fBGEM_AFTER_INSTALL_ALL\fR (\fBafter\-install\-all\fR)
|
|
116
|
+
Called after all gems are installed, with an Array of the \fBBundler::Dependency\fR objects declared in the Gemfile\.
|
|
117
|
+
.P
|
|
118
|
+
\fBREQUIRE\fR
|
|
119
|
+
.P
|
|
120
|
+
These events fire from \fBBundler\.require\fR\.
|
|
121
|
+
.TP
|
|
122
|
+
\fBGEM_BEFORE_REQUIRE_ALL\fR (\fBbefore\-require\-all\fR)
|
|
123
|
+
Called before any gem is required, with an Array of the \fBBundler::Dependency\fR objects being required\.
|
|
124
|
+
.TP
|
|
125
|
+
\fBGEM_BEFORE_REQUIRE\fR (\fBbefore\-require\fR)
|
|
126
|
+
Called before each individual gem is required, with its \fBBundler::Dependency\fR\.
|
|
127
|
+
.TP
|
|
128
|
+
\fBGEM_AFTER_REQUIRE\fR (\fBafter\-require\fR)
|
|
129
|
+
Called after each individual gem is required, with its \fBBundler::Dependency\fR\.
|
|
130
|
+
.TP
|
|
131
|
+
\fBGEM_AFTER_REQUIRE_ALL\fR (\fBafter\-require\-all\fR)
|
|
132
|
+
Called after all gems are required, with an Array of the \fBBundler::Dependency\fR objects that were required\.
|
|
72
133
|
.SH "SEE ALSO"
|
|
73
134
|
.IP "\(bu" 4
|
|
74
135
|
How to write a Bundler plugin \fIhttps://guides\.rubygems\.org/bundler_plugins/\fR
|