rubygems-update 4.0.23 → 4.0.25
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 +24 -0
- data/bundler/CHANGELOG.md +31 -0
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli/exec.rb +1 -1
- data/bundler/lib/bundler/cli/lock.rb +5 -1
- data/bundler/lib/bundler/cli/outdated.rb +1 -4
- data/bundler/lib/bundler/definition.rb +13 -5
- data/bundler/lib/bundler/dependency.rb +17 -2
- data/bundler/lib/bundler/dsl.rb +6 -2
- data/bundler/lib/bundler/fetcher.rb +4 -1
- data/bundler/lib/bundler/injector.rb +1 -1
- data/bundler/lib/bundler/man/gemfile.5 +2 -0
- data/bundler/lib/bundler/man/gemfile.5.ronn +6 -0
- data/bundler/lib/bundler/mirror.rb +7 -5
- data/bundler/lib/bundler/plugin/index.rb +29 -3
- data/bundler/lib/bundler/resolver.rb +57 -5
- data/bundler/lib/bundler/ruby_dsl.rb +2 -1
- data/bundler/lib/bundler/rubygems_ext.rb +15 -4
- data/bundler/lib/bundler/source/rubygems.rb +1 -1
- data/bundler/lib/bundler/spec_set.rb +3 -3
- data/bundler/lib/bundler/version.rb +1 -1
- data/lib/rubygems/core_ext/tcpsocket_init.rb +2 -2
- data/lib/rubygems/ext/builder.rb +1 -1
- data/lib/rubygems/package/old.rb +2 -2
- data/lib/rubygems/package.rb +45 -12
- data/lib/rubygems/uninstaller.rb +14 -2
- data/lib/rubygems/user_interaction.rb +6 -9
- data/lib/rubygems.rb +23 -7
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19a887e090c63e47ee3525f0d74cabae85a510aa3066dc98e27ef099ee23f83b
|
|
4
|
+
data.tar.gz: 0e9cd05343e09f62c50c273611b2f03cba6c8553c2ccb60b32d432a2719a01b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45c4cc9046f9ad488df12ca73d89e15e1d092ba0dfb12e438f41eef2186b2084cc1e5b03de8bdaa47a98317216ef3da92e198afe61711880ea7b5204982d5d01
|
|
7
|
+
data.tar.gz: 548ed1fbf6157750db5dd1fc9bf2ca3d5b732f4ba6009bdf02e22883d006eac40ab7c18200d1a57f1657570b4909574134c24b9f3c760d682f6c4be38e60050f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.25 / 2026-11-25
|
|
4
|
+
|
|
5
|
+
### Bug fixes:
|
|
6
|
+
|
|
7
|
+
* Fix file permissions during gem extraction. Pull request [#10128](https://github.com/ruby/rubygems/pull/10128) by Hiroshi SHIBATA
|
|
8
|
+
* Resolve chained symlink targets before creating them during extraction. Pull request [#10119](https://github.com/ruby/rubygems/pull/10119) by Hiroshi SHIBATA
|
|
9
|
+
* Forward keyword arguments in the IPv4 fallback TCPSocket#initialize. Pull request [#10098](https://github.com/ruby/rubygems/pull/10098) by Hiroshi SHIBATA
|
|
10
|
+
|
|
11
|
+
## 4.0.24 / 2026-11-05
|
|
12
|
+
|
|
13
|
+
### Enhancements:
|
|
14
|
+
|
|
15
|
+
* Installs bundler 4.0.24 as a default gem.
|
|
16
|
+
|
|
17
|
+
### Bug fixes:
|
|
18
|
+
|
|
19
|
+
* Skip executable removal gracefully when the bin directory is missing. Pull request [#9963](https://github.com/ruby/rubygems/pull/9963) by Evan Li and Hiroshi SHIBATA
|
|
20
|
+
* Fix file locks letting multiple processes in when lock files are removed. Pull request [#9930](https://github.com/ruby/rubygems/pull/9930) by Richard Janita and Hiroshi SHIBATA
|
|
21
|
+
* Turn off echo before printing the password prompt. Pull request [#9969](https://github.com/ruby/rubygems/pull/9969) by Mike Dalessio
|
|
22
|
+
|
|
23
|
+
### Documentation:
|
|
24
|
+
|
|
25
|
+
* [DOC] Fix link. Pull request [#10014](https://github.com/ruby/rubygems/pull/10014) by Burdette Lamar
|
|
26
|
+
|
|
3
27
|
## 4.0.23 / 2026-10-14
|
|
4
28
|
|
|
5
29
|
### Enhancements:
|
data/bundler/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.25 / 2026-11-25
|
|
4
|
+
|
|
5
|
+
### Bug fixes:
|
|
6
|
+
|
|
7
|
+
* Retry resolution with transitive prereleases. Pull request [#10110](https://github.com/ruby/rubygems/pull/10110) by Hiroshi SHIBATA
|
|
8
|
+
* Allow full updates to downgrade a yanked gem. Pull request [#10106](https://github.com/ruby/rubygems/pull/10106) by Hiroshi SHIBATA
|
|
9
|
+
* Allow `bundle lock --add-platform` to add native platforms from JRuby. Pull request [#10105](https://github.com/ruby/rubygems/pull/10105) by Hiroshi SHIBATA
|
|
10
|
+
* Show fourth-segment and prerelease updates in `bundle outdated --filter-patch`. Pull request [#10103](https://github.com/ruby/rubygems/pull/10103) by Hiroshi SHIBATA
|
|
11
|
+
* Resolve dependencies before `bundle add` updates the Gemfile. Pull request [#10101](https://github.com/ruby/rubygems/pull/10101) by Hiroshi SHIBATA
|
|
12
|
+
* Read plugin index files that Bundler 4.1 writes. Pull request [#10077](https://github.com/ruby/rubygems/pull/10077) by Hiroshi SHIBATA
|
|
13
|
+
* Preload git sources that share a cache one after another: 4.0.x. Pull request [#10069](https://github.com/ruby/rubygems/pull/10069) by Hiroshi SHIBATA
|
|
14
|
+
* Fix Bundler mirror probing with `fallback_timeout`. Pull request [#10046](https://github.com/ruby/rubygems/pull/10046) by Hiroshi SHIBATA
|
|
15
|
+
|
|
16
|
+
## 4.0.24 / 2026-11-05
|
|
17
|
+
|
|
18
|
+
### Enhancements:
|
|
19
|
+
|
|
20
|
+
* Read the Ruby version from mise's inline table form. Pull request [#9991](https://github.com/ruby/rubygems/pull/9991) by Hiroshi SHIBATA
|
|
21
|
+
* Report which locked gems can't be materialized for the current platform. Pull request [#9738](https://github.com/ruby/rubygems/pull/9738) by Muhammad Moussa
|
|
22
|
+
|
|
23
|
+
### Bug fixes:
|
|
24
|
+
|
|
25
|
+
* Fix `bundle exec` with no arguments for paths containing spaces. Pull request [#9996](https://github.com/ruby/rubygems/pull/9996) by Brandon Weiss
|
|
26
|
+
* Respect enclosing platforms and install_if for gemspec development dependencies. Pull request [#9992](https://github.com/ruby/rubygems/pull/9992) by Hiroshi SHIBATA
|
|
27
|
+
* Respect enclosing group and platforms for gemspec dependencies. Pull request [#9990](https://github.com/ruby/rubygems/pull/9990) by Denis Talakevich
|
|
28
|
+
* Don't report locked gems in the cooldown summary. Pull request [#9981](https://github.com/ruby/rubygems/pull/9981) by Patrik Ragnarsson
|
|
29
|
+
* Make `Bundler::Source::Rubygems#hash` agree with `eql?`. Pull request [#9983](https://github.com/ruby/rubygems/pull/9983) by Hiroshi SHIBATA
|
|
30
|
+
* Add checksums after platform changes in `bundle lock`. Pull request [#9960](https://github.com/ruby/rubygems/pull/9960) by Farid Zakaria
|
|
31
|
+
* Apply BUNDLE_RETRY to lazy gemspec downloads. Pull request [#9868](https://github.com/ruby/rubygems/pull/9868) by Islam Elsayed
|
|
32
|
+
* Fix file locks letting multiple processes in when lock files are removed. Pull request [#9930](https://github.com/ruby/rubygems/pull/9930) by Richard Janita and Hiroshi SHIBATA
|
|
33
|
+
|
|
3
34
|
## 4.0.23 / 2026-10-14
|
|
4
35
|
|
|
5
36
|
### Enhancements:
|
|
@@ -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-
|
|
8
|
-
@git_commit_sha = "
|
|
7
|
+
@built_at = "2026-11-25".freeze
|
|
8
|
+
@git_commit_sha = "0b572c1".freeze
|
|
9
9
|
# end ivars
|
|
10
10
|
|
|
11
11
|
# A hash representation of the build metadata.
|
|
@@ -43,7 +43,6 @@ module Bundler
|
|
|
43
43
|
|
|
44
44
|
Bundler.settings.temporary(frozen: false) do
|
|
45
45
|
definition = Bundler.definition(update, Bundler.default_lockfile)
|
|
46
|
-
definition.add_checksums if options["add-checksums"]
|
|
47
46
|
|
|
48
47
|
Bundler::CLI::Common.configure_gem_version_promoter(definition, options) if options[:update]
|
|
49
48
|
|
|
@@ -65,6 +64,11 @@ module Bundler
|
|
|
65
64
|
raise InvalidOption, "Removing all platforms from the bundle is not allowed"
|
|
66
65
|
end
|
|
67
66
|
|
|
67
|
+
# Adding checksums resolves the bundle to fetch them, so it has to
|
|
68
|
+
# run after every platform change above has been recorded, or the
|
|
69
|
+
# new platforms are listed in the lockfile without their specs.
|
|
70
|
+
definition.add_checksums if options["add-checksums"]
|
|
71
|
+
|
|
68
72
|
definition.remotely! unless options[:local]
|
|
69
73
|
|
|
70
74
|
if options["normalize-platforms"]
|
|
@@ -303,10 +303,7 @@ module Bundler
|
|
|
303
303
|
update_present = active_minor > current_minor if options["filter-minor"]
|
|
304
304
|
|
|
305
305
|
if !update_present && options["filter-patch"] && current_minor == active_minor
|
|
306
|
-
|
|
307
|
-
active_patch = get_version_semver_portion_value(active_spec, 2)
|
|
308
|
-
|
|
309
|
-
update_present = active_patch > current_patch
|
|
306
|
+
update_present = active_spec.version > current_spec.version
|
|
310
307
|
end
|
|
311
308
|
end
|
|
312
309
|
|
|
@@ -748,7 +748,9 @@ module Bundler
|
|
|
748
748
|
loop do
|
|
749
749
|
break if incomplete_specs.empty?
|
|
750
750
|
|
|
751
|
-
Bundler.ui.debug("The lockfile does not have all gems needed for the current platform though,
|
|
751
|
+
Bundler.ui.debug("The lockfile does not have all gems needed for the current platform (#{Bundler.local_platform}) though, " \
|
|
752
|
+
"Bundler will still re-resolve dependencies. The following locked gems could not be materialized for it: " \
|
|
753
|
+
"#{incomplete_specs.map(&:full_name).join(", ")}")
|
|
752
754
|
sources.remote!
|
|
753
755
|
reresolve_without(incomplete_specs)
|
|
754
756
|
specs = resolve.materialize(dependencies)
|
|
@@ -793,10 +795,10 @@ module Bundler
|
|
|
793
795
|
@resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version
|
|
794
796
|
|
|
795
797
|
@new_platforms.each do |platform|
|
|
796
|
-
incomplete_specs = result.incomplete_specs_for_platform(
|
|
798
|
+
incomplete_specs = result.incomplete_specs_for_platform(dependencies, platform)
|
|
797
799
|
|
|
798
800
|
if incomplete_specs.any?
|
|
799
|
-
resolver.raise_incomplete! incomplete_specs
|
|
801
|
+
resolver.raise_incomplete! incomplete_specs, platform
|
|
800
802
|
end
|
|
801
803
|
end
|
|
802
804
|
|
|
@@ -1179,7 +1181,7 @@ module Bundler
|
|
|
1179
1181
|
def preload_git_source_worker
|
|
1180
1182
|
workers = Bundler.settings.installation_parallelization
|
|
1181
1183
|
|
|
1182
|
-
@preload_git_source_worker ||= Bundler::Worker.new(workers, "Git source preloading", ->(
|
|
1184
|
+
@preload_git_source_worker ||= Bundler::Worker.new(workers, "Git source preloading", ->(sources, _) { sources.each(&:specs) })
|
|
1183
1185
|
end
|
|
1184
1186
|
|
|
1185
1187
|
def preload_git_sources
|
|
@@ -1190,7 +1192,13 @@ module Bundler
|
|
|
1190
1192
|
end
|
|
1191
1193
|
|
|
1192
1194
|
begin
|
|
1193
|
-
|
|
1195
|
+
# Sources from the same repository share one cache directory, and
|
|
1196
|
+
# running git in that directory from two workers at once makes the
|
|
1197
|
+
# fetches collide. Preload sources that share a cache in one job, one
|
|
1198
|
+
# after the other, and run the separate caches in parallel.
|
|
1199
|
+
needed_git_sources.group_by(&:cache_path).each_value do |sources|
|
|
1200
|
+
preload_git_source_worker.enq(sources)
|
|
1201
|
+
end
|
|
1194
1202
|
ensure
|
|
1195
1203
|
preload_git_source_worker.stop
|
|
1196
1204
|
end
|
|
@@ -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?
|
|
@@ -147,5 +147,20 @@ module Bundler
|
|
|
147
147
|
rescue NoMethodError
|
|
148
148
|
requirement != ">= 0"
|
|
149
149
|
end
|
|
150
|
+
|
|
151
|
+
private
|
|
152
|
+
|
|
153
|
+
def matches_platform?(platform)
|
|
154
|
+
return true if platforms.empty?
|
|
155
|
+
|
|
156
|
+
generic = Gem::Platform.generic(platform)
|
|
157
|
+
platforms.any? do |name|
|
|
158
|
+
next false unless [CurrentRuby::PLATFORM_MAP[name]].flatten.include?(generic)
|
|
159
|
+
next Bundler.current_ruby.public_send("#{name}?") if generic == Bundler.generic_local_platform
|
|
160
|
+
|
|
161
|
+
version = name.to_s[/_(\d+)\z/, 1]
|
|
162
|
+
!version || Bundler.current_ruby.public_send("on_#{version}?")
|
|
163
|
+
end
|
|
164
|
+
end
|
|
150
165
|
end
|
|
151
166
|
end
|
data/bundler/lib/bundler/dsl.rb
CHANGED
|
@@ -80,11 +80,15 @@ module Bundler
|
|
|
80
80
|
@gemspecs << spec
|
|
81
81
|
|
|
82
82
|
path path, "glob" => glob, "name" => spec.name, "gemspec" => spec do
|
|
83
|
-
|
|
83
|
+
options = {}
|
|
84
|
+
normalize_options(spec.name, [], options)
|
|
85
|
+
add_dependency spec.name, nil, options
|
|
84
86
|
end
|
|
85
87
|
|
|
86
88
|
spec.development_dependencies.each do |dep|
|
|
87
|
-
|
|
89
|
+
options = {}
|
|
90
|
+
normalize_options(dep.name, dep.requirement.as_list, options)
|
|
91
|
+
add_dependency dep.name, dep.requirement.as_list, options.merge("gemspec_dev_dep" => true, "group" => development_group)
|
|
88
92
|
end
|
|
89
93
|
when 0
|
|
90
94
|
raise InvalidOption, "There are no gemspecs at #{expanded_path}"
|
|
@@ -156,7 +156,10 @@ module Bundler
|
|
|
156
156
|
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
|
|
157
157
|
Bundler.load_gemspec(cached_spec_path)
|
|
158
158
|
else
|
|
159
|
-
|
|
159
|
+
body = Bundler::Retry.new("fetcher", FAIL_ERRORS).attempts do
|
|
160
|
+
downloader.fetch(uri).body
|
|
161
|
+
end
|
|
162
|
+
Bundler.safe_load_marshal Bundler.rubygems.inflate(body)
|
|
160
163
|
end
|
|
161
164
|
raise MarshalError, "is #{spec.inspect}" unless spec.is_a?(Gem::Specification)
|
|
162
165
|
spec
|
|
@@ -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?
|
|
@@ -461,6 +461,8 @@ The \fBgemspec\fR method adds any runtime dependencies as gem requirements in th
|
|
|
461
461
|
.P
|
|
462
462
|
The \fBgemspec\fR method supports optional \fB:path\fR, \fB:glob\fR, \fB:name\fR, and \fB:development_group\fR options, which control where bundler looks for the \fB\.gemspec\fR, the glob it uses to look for the gemspec (defaults to: \fB{,*,*/*}\.gemspec\fR), what named \fB\.gemspec\fR it uses (if more than one is present), and which group development dependencies are included in\.
|
|
463
463
|
.P
|
|
464
|
+
When \fBgemspec\fR is called inside a \fBgroup\fR block, the gem requirement on your project goes into that group instead of the default group, and so do its runtime dependencies\. Development dependencies stay in the \fBdevelopment\fR group, or the group given by \fB:development_group\fR\. An enclosing \fBplatforms\fR or \fBinstall_if\fR block applies to the project and its development dependencies alike\.
|
|
465
|
+
.P
|
|
464
466
|
When a \fBgemspec\fR dependency encounters version conflicts during resolution, the local version under development will always be selected \-\- even if there are remote versions that better match other requirements for the \fBgemspec\fR gem\.
|
|
465
467
|
.SH "EVAL_GEMFILE"
|
|
466
468
|
A Gemfile \fBMAY\fR be split across multiple files\. The \fBeval_gemfile\fR method reads the contents of another file as if they appeared in the current Gemfile\. A relative path is resolved against the directory of the file containing the call\.
|
|
@@ -546,6 +546,12 @@ options, which control where bundler looks for the `.gemspec`, the glob it uses
|
|
|
546
546
|
for the gemspec (defaults to: `{,*,*/*}.gemspec`), what named `.gemspec` it uses
|
|
547
547
|
(if more than one is present), and which group development dependencies are included in.
|
|
548
548
|
|
|
549
|
+
When `gemspec` is called inside a `group` block, the gem requirement on your
|
|
550
|
+
project goes into that group instead of the default group, and so do its runtime
|
|
551
|
+
dependencies. Development dependencies stay in the `development` group, or the
|
|
552
|
+
group given by `:development_group`. An enclosing `platforms` or `install_if`
|
|
553
|
+
block applies to the project and its development dependencies alike.
|
|
554
|
+
|
|
549
555
|
When a `gemspec` dependency encounters version conflicts during resolution, the
|
|
550
556
|
local version under development will always be selected -- even if there are
|
|
551
557
|
remote versions that better match other requirements for the `gemspec` gem.
|
|
@@ -151,9 +151,11 @@ module Bundler
|
|
|
151
151
|
socket.connect_nonblock(address)
|
|
152
152
|
rescue Errno::EINPROGRESS
|
|
153
153
|
wait_for_writtable_socket(socket, address, timeout)
|
|
154
|
-
rescue
|
|
154
|
+
rescue SystemCallError # Connection failed somehow, again
|
|
155
155
|
false
|
|
156
156
|
end
|
|
157
|
+
rescue SocketError # The mirror host does not resolve
|
|
158
|
+
false
|
|
157
159
|
end
|
|
158
160
|
|
|
159
161
|
private
|
|
@@ -185,7 +187,7 @@ module Bundler
|
|
|
185
187
|
class MirrorSockets
|
|
186
188
|
def initialize(mirror)
|
|
187
189
|
@timeout = mirror.fallback_timeout
|
|
188
|
-
@addresses = Socket.getaddrinfo(mirror.uri.
|
|
190
|
+
@addresses = Socket.getaddrinfo(mirror.uri.hostname, mirror.uri.port, nil, Socket::SOCK_STREAM).map do |address|
|
|
189
191
|
SocketAddress.new(address[0], address[3], address[1])
|
|
190
192
|
end
|
|
191
193
|
end
|
|
@@ -194,9 +196,9 @@ module Bundler
|
|
|
194
196
|
@addresses.any? do |address|
|
|
195
197
|
socket = Socket.new(Socket.const_get(address.type), Socket::SOCK_STREAM, 0)
|
|
196
198
|
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
yield socket, address.to_socket_address, @timeout
|
|
200
|
+
ensure
|
|
201
|
+
socket&.close
|
|
200
202
|
end
|
|
201
203
|
end
|
|
202
204
|
end
|
|
@@ -163,6 +163,8 @@ module Bundler
|
|
|
163
163
|
# @param [Pathname] index file path
|
|
164
164
|
# @param [Boolean] is the index file global index
|
|
165
165
|
def load_index(index_file, global = false)
|
|
166
|
+
base = global ? Plugin.global_root : Plugin.root
|
|
167
|
+
|
|
166
168
|
SharedHelpers.filesystem_access(index_file, :read) do |index_f|
|
|
167
169
|
valid_file = index_f&.exist? && !index_f.size.zero?
|
|
168
170
|
break unless valid_file
|
|
@@ -170,16 +172,40 @@ module Bundler
|
|
|
170
172
|
data = index_f.read
|
|
171
173
|
|
|
172
174
|
require_relative "../yaml_serializer"
|
|
173
|
-
|
|
175
|
+
loaded = YAMLSerializer.load(data)
|
|
176
|
+
# Bundler 4.1 writes empty sections as "{}", which this serializer
|
|
177
|
+
# reads as a string.
|
|
178
|
+
index = %w[commands hooks load_paths plugin_paths sources].to_h do |key|
|
|
179
|
+
[key, loaded[key].is_a?(Hash) ? loaded[key] : {}]
|
|
180
|
+
end
|
|
174
181
|
|
|
175
182
|
@commands.merge!(index["commands"])
|
|
176
183
|
@hooks.merge!(index["hooks"])
|
|
177
|
-
@load_paths.merge!(index["load_paths"])
|
|
178
|
-
@plugin_paths.merge!(index["plugin_paths"])
|
|
184
|
+
@load_paths.merge!(absolutize_paths(index["load_paths"], base))
|
|
185
|
+
@plugin_paths.merge!(absolutize_paths(index["plugin_paths"], base))
|
|
179
186
|
@sources.merge!(index["sources"]) unless global
|
|
180
187
|
end
|
|
181
188
|
end
|
|
182
189
|
|
|
190
|
+
# Bundler 4.1 records the paths of a plugin installed in the plugin root
|
|
191
|
+
# relative to it.
|
|
192
|
+
def absolutize_paths(paths, base)
|
|
193
|
+
paths.transform_values do |value|
|
|
194
|
+
if value.is_a?(Array)
|
|
195
|
+
value.map {|path| absolutize_path(path, base) }
|
|
196
|
+
else
|
|
197
|
+
absolutize_path(value, base)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def absolutize_path(path, base)
|
|
203
|
+
pathname = Pathname.new(path)
|
|
204
|
+
return path if pathname.absolute?
|
|
205
|
+
|
|
206
|
+
Pathname.new(base).join(pathname).to_s
|
|
207
|
+
end
|
|
208
|
+
|
|
183
209
|
# Should be called when any of the instance variables change. Stores the
|
|
184
210
|
# instance variables in YAML format. (The instance variables are supposed
|
|
185
211
|
# to be only String key value pairs)
|
|
@@ -137,8 +137,10 @@ module Bundler
|
|
|
137
137
|
names_to_allow_remote_specs_for = []
|
|
138
138
|
extended_explanation = nil
|
|
139
139
|
|
|
140
|
+
satisfiers = []
|
|
140
141
|
while incompatibility.conflict?
|
|
141
142
|
cause = incompatibility.cause
|
|
143
|
+
satisfiers << cause.satisfier
|
|
142
144
|
incompatibility = cause.incompatibility
|
|
143
145
|
|
|
144
146
|
incompatibility.terms.each do |term|
|
|
@@ -147,7 +149,7 @@ module Bundler
|
|
|
147
149
|
|
|
148
150
|
if base_requirements[name]
|
|
149
151
|
names_to_unlock << name
|
|
150
|
-
elsif package
|
|
152
|
+
elsif filtered_prereleases?(package)
|
|
151
153
|
names_to_allow_prereleases_for << name
|
|
152
154
|
elsif package.prefer_local? && @all_specs[name].any? {|s| !s.is_a?(StubSpecification) }
|
|
153
155
|
names_to_allow_remote_specs_for << name
|
|
@@ -160,6 +162,11 @@ module Bundler
|
|
|
160
162
|
end
|
|
161
163
|
end
|
|
162
164
|
|
|
165
|
+
# Preserve the usual retry order when it can already resolve the conflict.
|
|
166
|
+
if names_to_unlock.empty? && names_to_allow_prereleases_for.empty? && names_to_allow_remote_specs_for.empty?
|
|
167
|
+
names_to_allow_prereleases_for = prerelease_names_in(satisfiers)
|
|
168
|
+
end
|
|
169
|
+
|
|
163
170
|
[names_to_unlock.uniq, names_to_allow_prereleases_for.uniq, names_to_allow_remote_specs_for.uniq, extended_explanation]
|
|
164
171
|
end
|
|
165
172
|
|
|
@@ -321,8 +328,10 @@ module Bundler
|
|
|
321
328
|
"Gemfile"
|
|
322
329
|
end
|
|
323
330
|
|
|
324
|
-
def raise_incomplete!(incomplete_specs)
|
|
325
|
-
|
|
331
|
+
def raise_incomplete!(incomplete_specs, platform = nil)
|
|
332
|
+
spec = incomplete_specs.first
|
|
333
|
+
# An unresolved dependency may be missing for a different resolution platform.
|
|
334
|
+
raise_not_found!(@base.get_package(spec.name), spec.version && platform)
|
|
326
335
|
end
|
|
327
336
|
|
|
328
337
|
def sort_versions_by_preferred(package, versions)
|
|
@@ -331,7 +340,7 @@ module Bundler
|
|
|
331
340
|
|
|
332
341
|
private
|
|
333
342
|
|
|
334
|
-
def raise_not_found!(package)
|
|
343
|
+
def raise_not_found!(package, platform = nil)
|
|
335
344
|
name = package.name
|
|
336
345
|
source = source_for(name)
|
|
337
346
|
specs = @all_specs[name]
|
|
@@ -347,7 +356,7 @@ module Bundler
|
|
|
347
356
|
not_found_message = if specs_matching_requirement.any?
|
|
348
357
|
specs = specs_matching_requirement
|
|
349
358
|
matching_part = requirement_label
|
|
350
|
-
platforms = package.platforms
|
|
359
|
+
platforms = platform ? [platform] : package.platforms
|
|
351
360
|
|
|
352
361
|
if platforms.size == 1
|
|
353
362
|
"Could not find gem '#{requirement_label}' with platform '#{platforms.first}'"
|
|
@@ -414,6 +423,30 @@ module Bundler
|
|
|
414
423
|
filter_remote_specs(filter_cooldown(filter_prereleases(specs, package)), package)
|
|
415
424
|
end
|
|
416
425
|
|
|
426
|
+
def prerelease_names_in(incompatibilities)
|
|
427
|
+
seen = {}.compare_by_identity
|
|
428
|
+
packages = []
|
|
429
|
+
while (incompatibility = incompatibilities.pop)
|
|
430
|
+
next if seen[incompatibility]
|
|
431
|
+
seen[incompatibility] = true
|
|
432
|
+
|
|
433
|
+
if incompatibility.conflict?
|
|
434
|
+
cause = incompatibility.cause
|
|
435
|
+
incompatibilities.push(cause.incompatibility, cause.satisfier)
|
|
436
|
+
else
|
|
437
|
+
incompatibility.terms.each {|term| packages << term.package }
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
packages.uniq.filter_map do |package|
|
|
442
|
+
package.name if !base_requirements[package.name] && filtered_prereleases?(package)
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
def filtered_prereleases?(package)
|
|
447
|
+
package.ignores_prereleases? && @all_specs[package.name].any? {|s| s.version.prerelease? }
|
|
448
|
+
end
|
|
449
|
+
|
|
417
450
|
def filter_prereleases(specs, package)
|
|
418
451
|
return specs unless package.ignores_prereleases? && specs.size > 1
|
|
419
452
|
|
|
@@ -499,6 +532,8 @@ module Bundler
|
|
|
499
532
|
@cooldown_skipped_specs.each do |(name, version), spec|
|
|
500
533
|
resolved = resolved_versions[name]
|
|
501
534
|
next unless resolved && version > resolved
|
|
535
|
+
package = @base.get_package(name)
|
|
536
|
+
next if !package.unlock? && package.locked_version == resolved
|
|
502
537
|
next unless requirements[name].all? {|req| req.satisfied_by?(version) }
|
|
503
538
|
newest = newest_skipped[name]
|
|
504
539
|
newest_skipped[name] = spec if newest.nil? || version > newest.version
|
|
@@ -571,6 +606,13 @@ module Bundler
|
|
|
571
606
|
versions = versions_for(dep_package, dep_range)
|
|
572
607
|
end
|
|
573
608
|
|
|
609
|
+
if versions.empty? && locked_version_missing?(dep_package)
|
|
610
|
+
@base.unlock_names([name])
|
|
611
|
+
@all_versions.delete(dep_package)
|
|
612
|
+
@sorted_versions.delete(dep_package)
|
|
613
|
+
versions = versions_for(dep_package, dep_range)
|
|
614
|
+
end
|
|
615
|
+
|
|
574
616
|
if versions.empty? && select_all_versions(dep_package, dep_range).any?
|
|
575
617
|
raise_all_versions_filtered_out!(dep_package)
|
|
576
618
|
end
|
|
@@ -583,6 +625,16 @@ module Bundler
|
|
|
583
625
|
end.to_h
|
|
584
626
|
end
|
|
585
627
|
|
|
628
|
+
def locked_version_missing?(package)
|
|
629
|
+
return false unless package.unlock?
|
|
630
|
+
|
|
631
|
+
name = package.name
|
|
632
|
+
version = package.locked_version
|
|
633
|
+
return false unless base_requirements[name]&.requirements == [[">=", version]]
|
|
634
|
+
|
|
635
|
+
source_for(name).specs.search([name, version]).empty?
|
|
636
|
+
end
|
|
637
|
+
|
|
586
638
|
def select_all_versions(package, range)
|
|
587
639
|
range.select_versions(@all_versions[package])
|
|
588
640
|
end
|
|
@@ -42,11 +42,12 @@ module Bundler
|
|
|
42
42
|
# Loads the file relative to the dirname of the Gemfile itself.
|
|
43
43
|
def normalize_ruby_file(filename)
|
|
44
44
|
file_content = Bundler.read_file(gemfile.dirname.join(filename))
|
|
45
|
-
# match "ruby-3.2.2", ruby = "3.2.2", ruby = '3.2.2' or "ruby 3.2.2" capturing version string up to the first space or comment
|
|
45
|
+
# match "ruby-3.2.2", ruby = "3.2.2", ruby = '3.2.2', ruby = { version = "3.2.2" } or "ruby 3.2.2" capturing version string up to the first space or comment
|
|
46
46
|
version_match = /^ # Start of line
|
|
47
47
|
ruby # Literal "ruby"
|
|
48
48
|
[\s-]* # Optional whitespace or hyphens (for "ruby-3.2.2" format)
|
|
49
49
|
(?:=\s*)? # Optional equals sign with whitespace (for ruby = "3.2.2" format)
|
|
50
|
+
(?:\{[^}]*?\bversion\s*=\s*)? # Optional inline table up to its version key (for ruby = { version = "3.2.2" } format)
|
|
50
51
|
(?:
|
|
51
52
|
"([^"]+)" # Double quoted version
|
|
52
53
|
|
|
|
@@ -40,11 +40,22 @@ module Gem
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
def open_file_with_lock(path
|
|
43
|
+
def open_file_with_lock(path)
|
|
44
44
|
file_lock = "#{path}.lock"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
|
|
46
|
+
loop do
|
|
47
|
+
open_file_with_flock(file_lock) do |io|
|
|
48
|
+
# The previous holder removed the file while we were waiting on it,
|
|
49
|
+
# so leave this block and try again on the file now at the lock path
|
|
50
|
+
next unless File.identical?(io, file_lock)
|
|
51
|
+
|
|
52
|
+
begin
|
|
53
|
+
return yield io
|
|
54
|
+
ensure
|
|
55
|
+
FileUtils.rm_f file_lock
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
48
59
|
end
|
|
49
60
|
end
|
|
50
61
|
end
|
|
@@ -140,14 +140,14 @@ module Bundler
|
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
def incomplete_for_platform?(deps, platform)
|
|
143
|
+
return false if @specs.empty?
|
|
144
|
+
|
|
143
145
|
incomplete_specs_for_platform(deps, platform).any?
|
|
144
146
|
end
|
|
145
147
|
|
|
146
148
|
def incomplete_specs_for_platform(deps, platform)
|
|
147
|
-
return [] if @specs.empty?
|
|
148
|
-
|
|
149
149
|
validation_set = self.class.new(@specs)
|
|
150
|
-
validation_set.for(deps, [platform])
|
|
150
|
+
validation_set.for(deps.select {|dep| dep.should_include?(platform) }, [platform])
|
|
151
151
|
validation_set.incomplete_specs
|
|
152
152
|
end
|
|
153
153
|
|
|
@@ -12,7 +12,7 @@ module CoreExtensions
|
|
|
12
12
|
CONNECTION_TIMEOUT = 5
|
|
13
13
|
IPV4_DELAY_SECONDS = 0.1
|
|
14
14
|
|
|
15
|
-
def initialize(host, serv,
|
|
15
|
+
def initialize(host, serv, ...)
|
|
16
16
|
mutex = Thread::Mutex.new
|
|
17
17
|
addrs = []
|
|
18
18
|
threads = []
|
|
@@ -45,7 +45,7 @@ module CoreExtensions
|
|
|
45
45
|
|
|
46
46
|
threads.each {|t| t.kill.join if t.alive? }
|
|
47
47
|
|
|
48
|
-
super(host, serv,
|
|
48
|
+
super(host, serv, ...)
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
end
|
data/lib/rubygems/ext/builder.rb
CHANGED
|
@@ -155,7 +155,7 @@ class Gem::Ext::Builder
|
|
|
155
155
|
end
|
|
156
156
|
|
|
157
157
|
##
|
|
158
|
-
# Splits a command string such as ENV["MAKE"] into an argument list.
|
|
158
|
+
# Splits a command string such as <tt>ENV["MAKE"]</tt> into an argument list.
|
|
159
159
|
#
|
|
160
160
|
# On Windows, a value that names an existing file, such as
|
|
161
161
|
# <tt>C:\path\nmake.exe</tt>, is taken as a single word because POSIX
|
data/lib/rubygems/package/old.rb
CHANGED
|
@@ -79,10 +79,10 @@ class Gem::Package::Old < Gem::Package
|
|
|
79
79
|
raise Gem::Package::FormatError, "#{full_name} in #{@gem} is corrupt" if
|
|
80
80
|
file_data.length != entry["size"].to_i
|
|
81
81
|
|
|
82
|
-
FileUtils.mkdir_p File.dirname(destination), mode: dir_mode && 0o755
|
|
83
|
-
|
|
84
82
|
verify_extraction_dir File.dirname(destination), destination_dir
|
|
85
83
|
|
|
84
|
+
FileUtils.mkdir_p File.dirname(destination), mode: dir_mode && 0o755
|
|
85
|
+
|
|
86
86
|
FileUtils.rm_rf destination
|
|
87
87
|
|
|
88
88
|
File.open destination, "wb", file_mode(entry["mode"]) do |out|
|
data/lib/rubygems/package.rb
CHANGED
|
@@ -432,6 +432,10 @@ EOM
|
|
|
432
432
|
|
|
433
433
|
def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
|
|
434
434
|
destination_dir = File.realpath(destination_dir)
|
|
435
|
+
# File.umask sets the process umask to 0 while reading it, so read it once
|
|
436
|
+
# instead of per file to keep other threads' files from being created
|
|
437
|
+
# world-writable.
|
|
438
|
+
umask = File.umask
|
|
435
439
|
|
|
436
440
|
directories = []
|
|
437
441
|
symlinks = []
|
|
@@ -455,7 +459,7 @@ EOM
|
|
|
455
459
|
raise Gem::Package::SymlinkError.new(full_name, real_destination, destination_dir) unless
|
|
456
460
|
normalize_path(real_destination).start_with? normalize_path(destination_dir + "/")
|
|
457
461
|
|
|
458
|
-
symlinks << [full_name, link_target, destination
|
|
462
|
+
symlinks << [full_name, link_target, destination]
|
|
459
463
|
end
|
|
460
464
|
|
|
461
465
|
mkdir =
|
|
@@ -465,13 +469,13 @@ EOM
|
|
|
465
469
|
File.dirname destination
|
|
466
470
|
end
|
|
467
471
|
|
|
472
|
+
verify_extraction_dir mkdir, destination_dir
|
|
473
|
+
|
|
468
474
|
unless directories.include?(mkdir)
|
|
469
|
-
FileUtils.mkdir_p mkdir, mode: dir_mode ? 0o755 : (entry.header.mode & 0o777 if entry.directory?)
|
|
475
|
+
FileUtils.mkdir_p mkdir, mode: dir_mode ? 0o755 : (entry.header.mode & 0o777 & ~umask if entry.directory?)
|
|
470
476
|
directories << mkdir
|
|
471
477
|
end
|
|
472
478
|
|
|
473
|
-
verify_extraction_dir mkdir, destination_dir
|
|
474
|
-
|
|
475
479
|
if entry.file?
|
|
476
480
|
File.open(destination, "wb") do |out|
|
|
477
481
|
copy_stream(tar.io, out, entry.size)
|
|
@@ -479,7 +483,7 @@ EOM
|
|
|
479
483
|
# in the IO buffer that needs to be written, and that could be
|
|
480
484
|
# written after the chmod (on close) which would mess up the perms
|
|
481
485
|
out.flush
|
|
482
|
-
out.chmod file_mode(entry.header.mode) & ~
|
|
486
|
+
out.chmod file_mode(entry.header.mode) & ~umask
|
|
483
487
|
end
|
|
484
488
|
end
|
|
485
489
|
|
|
@@ -487,12 +491,21 @@ EOM
|
|
|
487
491
|
end
|
|
488
492
|
end
|
|
489
493
|
|
|
490
|
-
symlinks.each do |name, target, destination
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
494
|
+
symlinks.each do |name, target, destination|
|
|
495
|
+
# The check above expands ".." lexically, so a target that walks
|
|
496
|
+
# through another symlink in the gem is only known once resolved.
|
|
497
|
+
real_destination = begin
|
|
498
|
+
resolve_symlink_target(target, File.dirname(destination))
|
|
499
|
+
rescue SystemCallError
|
|
500
|
+
gem_name = @spec ? @spec.full_name : "unknown"
|
|
501
|
+
alert_warning "#{gem_name} ships with a dangling symlink named #{name} pointing to missing #{target} file. Ignoring"
|
|
502
|
+
next
|
|
495
503
|
end
|
|
504
|
+
|
|
505
|
+
raise Gem::Package::SymlinkError.new(name, real_destination, destination_dir) unless
|
|
506
|
+
normalize_path(real_destination).start_with? normalize_path(destination_dir + "/")
|
|
507
|
+
|
|
508
|
+
create_symlink(target, destination)
|
|
496
509
|
end
|
|
497
510
|
|
|
498
511
|
if dir_mode
|
|
@@ -688,10 +701,13 @@ EOM
|
|
|
688
701
|
|
|
689
702
|
##
|
|
690
703
|
# Raises an exception unless +dir+, with symlinks resolved, is
|
|
691
|
-
# +destination_dir+ or a directory inside it. +
|
|
692
|
-
#
|
|
704
|
+
# +destination_dir+ or a directory inside it. When +dir+ does not exist
|
|
705
|
+
# yet, its nearest existing ancestor is checked instead, so this can run
|
|
706
|
+
# before +dir+ is created. +destination_dir+ must already be resolved with
|
|
707
|
+
# File.realpath by the caller.
|
|
693
708
|
|
|
694
709
|
def verify_extraction_dir(dir, destination_dir) # :nodoc:
|
|
710
|
+
dir = File.dirname(dir) until File.exist?(dir)
|
|
695
711
|
real_dir = File.realpath(dir)
|
|
696
712
|
|
|
697
713
|
return if real_dir == destination_dir ||
|
|
@@ -700,6 +716,23 @@ EOM
|
|
|
700
716
|
raise Gem::Package::PathError.new(real_dir, destination_dir)
|
|
701
717
|
end
|
|
702
718
|
|
|
719
|
+
##
|
|
720
|
+
# Resolves the symlink +target+ against +dir+ one component at a time.
|
|
721
|
+
# File.realpath on JRuby and TruffleRuby folds ".." before following
|
|
722
|
+
# symlinks, so ".." is applied here to the already resolved path instead.
|
|
723
|
+
|
|
724
|
+
def resolve_symlink_target(target, dir) # :nodoc:
|
|
725
|
+
root = target[%r{\A(?:[A-Za-z]:)?/}] if target.start_with?("/") || File.absolute_path?(target)
|
|
726
|
+
|
|
727
|
+
target.delete_prefix(root.to_s).split("/").inject(File.realpath(File.expand_path(root || dir))) do |current, name|
|
|
728
|
+
case name
|
|
729
|
+
when "", "." then current
|
|
730
|
+
when ".." then File.dirname(current)
|
|
731
|
+
else File.realpath(name, current)
|
|
732
|
+
end
|
|
733
|
+
end
|
|
734
|
+
end
|
|
735
|
+
|
|
703
736
|
##
|
|
704
737
|
# Verifies the +checksums+ against the +digests+. This check is not
|
|
705
738
|
# cryptographically secure. Missing checksums are ignored.
|
data/lib/rubygems/uninstaller.rb
CHANGED
|
@@ -208,6 +208,9 @@ class Gem::Uninstaller
|
|
|
208
208
|
|
|
209
209
|
return if executables.empty?
|
|
210
210
|
|
|
211
|
+
bin_dir = @bin_dir || Gem.bindir(spec.base_dir)
|
|
212
|
+
return if bin_dir_missing?(bin_dir)
|
|
213
|
+
|
|
211
214
|
executables = executables.map {|exec| formatted_program_filename exec }
|
|
212
215
|
|
|
213
216
|
remove = if @force_executables.nil?
|
|
@@ -220,8 +223,6 @@ class Gem::Uninstaller
|
|
|
220
223
|
end
|
|
221
224
|
|
|
222
225
|
if remove
|
|
223
|
-
bin_dir = @bin_dir || Gem.bindir(spec.base_dir)
|
|
224
|
-
|
|
225
226
|
raise Gem::FilePermissionError, bin_dir unless File.writable? bin_dir
|
|
226
227
|
|
|
227
228
|
executables.each do |exe_name|
|
|
@@ -398,6 +399,17 @@ class Gem::Uninstaller
|
|
|
398
399
|
|
|
399
400
|
private
|
|
400
401
|
|
|
402
|
+
# Only a directory that does not exist is skipped. Any other error, such as
|
|
403
|
+
# EACCES on a parent directory, is left to the writable check.
|
|
404
|
+
def bin_dir_missing?(bin_dir)
|
|
405
|
+
File.stat(bin_dir)
|
|
406
|
+
false
|
|
407
|
+
rescue Errno::ENOENT
|
|
408
|
+
true
|
|
409
|
+
rescue SystemCallError
|
|
410
|
+
false
|
|
411
|
+
end
|
|
412
|
+
|
|
401
413
|
def rm_r(path, exclusions:)
|
|
402
414
|
FileUtils::Entry_.new(path).postorder_traverse do |ent|
|
|
403
415
|
ent.remove unless exclusions.include?(ent.path)
|
|
@@ -295,10 +295,12 @@ class Gem::StreamUI
|
|
|
295
295
|
def ask_for_password(question)
|
|
296
296
|
return nil unless tty?
|
|
297
297
|
|
|
298
|
-
|
|
299
|
-
@
|
|
300
|
-
|
|
301
|
-
|
|
298
|
+
require_io_console
|
|
299
|
+
password = @ins.noecho do
|
|
300
|
+
@outs.print(question, " ")
|
|
301
|
+
@outs.flush
|
|
302
|
+
@ins.gets
|
|
303
|
+
end
|
|
302
304
|
@outs.puts
|
|
303
305
|
password&.chomp!
|
|
304
306
|
password
|
|
@@ -314,11 +316,6 @@ class Gem::StreamUI
|
|
|
314
316
|
end
|
|
315
317
|
end
|
|
316
318
|
|
|
317
|
-
def _gets_noecho
|
|
318
|
-
require_io_console
|
|
319
|
-
@ins.noecho { @ins.gets }
|
|
320
|
-
end
|
|
321
|
-
|
|
322
319
|
##
|
|
323
320
|
# Display a statement.
|
|
324
321
|
|
data/lib/rubygems.rb
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
require "rbconfig"
|
|
10
10
|
|
|
11
11
|
module Gem
|
|
12
|
-
VERSION = "4.0.
|
|
12
|
+
VERSION = "4.0.25"
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
require_relative "rubygems/defaults"
|
|
@@ -853,14 +853,30 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|
|
853
853
|
end
|
|
854
854
|
|
|
855
855
|
##
|
|
856
|
-
# Open a file with given flags, and protect access with a file lock
|
|
856
|
+
# Open a file with given flags, and protect access with a file lock.
|
|
857
|
+
#
|
|
858
|
+
# The lock file is removed once done, while still holding the lock. Since
|
|
859
|
+
# processes waiting for the lock may end up acquiring it on the removed file,
|
|
860
|
+
# after acquiring it we check that the locked file is still the one at the
|
|
861
|
+
# lock path, and start over otherwise.
|
|
857
862
|
|
|
858
|
-
def self.open_file_with_lock(path
|
|
863
|
+
def self.open_file_with_lock(path)
|
|
859
864
|
file_lock = "#{path}.lock"
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
865
|
+
|
|
866
|
+
loop do
|
|
867
|
+
open_file_with_flock(file_lock) do |io|
|
|
868
|
+
# The previous holder removed the file while we were waiting on it, so
|
|
869
|
+
# leave this block and try again on the file now at the lock path
|
|
870
|
+
next unless File.identical?(io, file_lock)
|
|
871
|
+
|
|
872
|
+
begin
|
|
873
|
+
return yield io
|
|
874
|
+
ensure
|
|
875
|
+
require "fileutils"
|
|
876
|
+
FileUtils.rm_f file_lock
|
|
877
|
+
end
|
|
878
|
+
end
|
|
879
|
+
end
|
|
864
880
|
end
|
|
865
881
|
|
|
866
882
|
##
|