rubygems-update 4.0.13 → 4.0.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0660c05e56df8027375e8d01d875fc71e9837ed53336eface4ce3caef8463b06
4
- data.tar.gz: 41fb9134ffe1423a57d10e9c3974c4fd03d02f31aea6da2d8703df407cb720c2
3
+ metadata.gz: 872371a3357601311ae655a4d31f14fe22ac4c581f07e56ce7c4e0a8e446c404
4
+ data.tar.gz: ac7b86aecc58b095555483690de516232b00a7c3ef95e42f4d6bdd84b2561b4a
5
5
  SHA512:
6
- metadata.gz: ad34acb0f898943a0a749765234e2ec3abec927d9d6eaffcbd5b33498dc04fe8f0a5477d7569a02a4792fdbaa058c05c14abe38c707c43568f2249c0855c050d
7
- data.tar.gz: 9bbb91eccb1401d2942b8817734b0130a6c7d33163f4faab4e3204d4f63bbbc317bb78e41a605b494d2224f4954c08d807e75ee3954def54a34e6410d08b85c6
6
+ metadata.gz: 8c48fb0c258070df0ce8b3bb8041e93b738ebdb927540d87fae2a6d2e52e4a9f811ad8e546a30900e73fd8ea14ee7d036626d15a9807ba224478313165e7f010
7
+ data.tar.gz: 2c890803e82d118d04b4fcdc1a090eb075ad4062eab6db4f395223f4bf95c045c1b46465912edfff7fda692b737c1724d5f1d7345c0bc84913c6a97c3135d36d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.15 / 2026-06-24
4
+
5
+ ### Enhancements:
6
+
7
+ * Rubygems: Fix Gem::Request for PQC support, adding integration connection tests. Pull request [#9615](https://github.com/ruby/rubygems/pull/9615) by junaruga
8
+ * Reduce peak memory usage of full index loading and bundle install. Pull request [#9618](https://github.com/ruby/rubygems/pull/9618) by hsbt
9
+ * Installs bundler 4.0.15 as a default gem.
10
+
11
+ ### Bug fixes:
12
+
13
+ * Forward security policy to old-format gems. Pull request [#9611](https://github.com/ruby/rubygems/pull/9611) by hsbt
14
+
15
+ ## 4.0.14 / 2026-06-10
16
+
17
+ ### Enhancements:
18
+
19
+ * Add executables and bindir validation to the gem installer. Pull request [#9595](https://github.com/ruby/rubygems/pull/9595) by hsbt
20
+ * Strip C1 control characters from displayed gem text. Pull request [#9597](https://github.com/ruby/rubygems/pull/9597) by hsbt
21
+ * Installs bundler 4.0.14 as a default gem.
22
+
3
23
  ## 4.0.13 / 2026-06-03
4
24
 
5
25
  ### Enhancements:
data/Manifest.txt CHANGED
@@ -167,6 +167,7 @@ bundler/lib/bundler/plugin/installer/git.rb
167
167
  bundler/lib/bundler/plugin/installer/path.rb
168
168
  bundler/lib/bundler/plugin/installer/rubygems.rb
169
169
  bundler/lib/bundler/plugin/source_list.rb
170
+ bundler/lib/bundler/plugin/unloaded_source.rb
170
171
  bundler/lib/bundler/process_lock.rb
171
172
  bundler/lib/bundler/remote_specification.rb
172
173
  bundler/lib/bundler/resolver.rb
data/bundler/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.15 / 2026-06-24
4
+
5
+ ### Enhancements:
6
+
7
+ * Resolve Git LFS files in git sources from the real remote. Pull request [#9632](https://github.com/ruby/rubygems/pull/9632) by hsbt
8
+ * Suggest access issues, not only yanking, for missing locked gems. Pull request [#9631](https://github.com/ruby/rubygems/pull/9631) by hsbt
9
+ * Implement a make jobserver (continuation of #9210). Pull request [#9625](https://github.com/ruby/rubygems/pull/9625) by hsbt
10
+ * Reduce peak memory usage of full index loading and bundle install. Pull request [#9618](https://github.com/ruby/rubygems/pull/9618) by hsbt
11
+ * Bump up to rb-sys 0.9.128. Pull request [#9569](https://github.com/ruby/rubygems/pull/9569) by hsbt
12
+
13
+ ### Bug fixes:
14
+
15
+ * Skip the make jobserver on Windows. Pull request [#9630](https://github.com/ruby/rubygems/pull/9630) by hsbt
16
+ * Don't require source plugins to be installed to parse a lockfile: 4.0.x. Pull request [#9621](https://github.com/ruby/rubygems/pull/9621) by hsbt
17
+ * Exempt lockfile versions from cooldown on every resolution path. Pull request [#9619](https://github.com/ruby/rubygems/pull/9619) by hsbt
18
+ * Set `Bundler.settings[:ssl_ca_cert]` to download gems. Pull request [#9610](https://github.com/ruby/rubygems/pull/9610) by junaruga
19
+
20
+ ## 4.0.14 / 2026-06-10
21
+
22
+ ### Bug fixes:
23
+
24
+ * Preserve per-source cooldown when converging sources from the lockfile. Pull request [#9601](https://github.com/ruby/rubygems/pull/9601) by bryanwoods
25
+ * Don't exclude the locked version from cooldown during bundle update. Pull request [#9599](https://github.com/ruby/rubygems/pull/9599) by hsbt
26
+
3
27
  ## 4.0.13 / 2026-06-03
4
28
 
5
29
  ### Enhancements:
@@ -5,7 +5,7 @@ module Bundler
5
5
  module BuildMetadata
6
6
  # begin ivars
7
7
  @built_at = nil
8
- @git_commit_sha = "003f20f0dc".freeze
8
+ @git_commit_sha = "12ba1f437b".freeze
9
9
  # end ivars
10
10
 
11
11
  # A hash representation of the build metadata.
@@ -230,6 +230,16 @@ module Bundler
230
230
  sources.prefer_local!
231
231
  end
232
232
 
233
+ # Releases memory only needed during resolution, such as remote spec
234
+ # indexes and resolver state. Only safe to call once resolution is
235
+ # complete and the result has been materialized, since any further
236
+ # resolution will need to refetch remote specs.
237
+ def release_resolution_memory!
238
+ @resolver = nil
239
+ @resolution_base = nil
240
+ sources.release_resolution_memory!
241
+ end
242
+
233
243
  # For given dependency list returns a SpecSet with Gemspec of all the required
234
244
  # dependencies.
235
245
  # 1. The method first resolves the dependencies specified in Gemfile
@@ -688,9 +698,10 @@ module Bundler
688
698
  "available locally before rerunning Bundler."
689
699
  else
690
700
  "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \
691
- "no longer be found in that source. That means the author of #{locked_gem} has removed it. " \
692
- "You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \
693
- "removed in order to install."
701
+ "no longer be found in that source. That means either the author of #{locked_gem} has removed it, " \
702
+ "or you no longer have access to that source. You'll need to update your bundle to a version other " \
703
+ "than #{locked_gem} that hasn't been removed, or check your credentials and access rights for " \
704
+ "#{locked_gem.source}, in order to install."
694
705
  end
695
706
 
696
707
  raise GemNotFound, message
@@ -1283,7 +1294,7 @@ module Bundler
1283
1294
 
1284
1295
  def new_resolution_base(last_resolve:, unlock:)
1285
1296
  new_resolution_platforms = @current_platform_missing ? @new_platforms + [Bundler.local_platform] : @new_platforms
1286
- Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, locked_specs: @originally_locked_specs, unlock: unlock, prerelease: gem_version_promoter.pre?, prefer_local: @prefer_local, new_platforms: new_resolution_platforms)
1297
+ Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, locked_specs: @originally_locked_specs, unlock: unlock, prerelease: gem_version_promoter.pre?, prefer_local: @prefer_local, new_platforms: new_resolution_platforms, explicit_unlocks: @explicit_unlocks)
1287
1298
  end
1288
1299
 
1289
1300
  def new_resolver(base)
@@ -38,6 +38,9 @@ module Bundler
38
38
  false
39
39
  end
40
40
 
41
+ def release_resolution_memory!
42
+ end
43
+
41
44
  private
42
45
 
43
46
  def log_specs(&block)
@@ -63,6 +63,13 @@ module Bundler
63
63
  true
64
64
  end
65
65
 
66
+ # The client holds the parsed checksums of all info files in the
67
+ # index. Dropping it is always safe because it is rebuilt from the
68
+ # local cache on demand.
69
+ def release_resolution_memory!
70
+ @compact_index_client = nil
71
+ end
72
+
66
73
  private
67
74
 
68
75
  def compact_index_client
@@ -73,6 +80,12 @@ module Bundler
73
80
  end
74
81
 
75
82
  def fetch_gem_infos(names)
83
+ # Create the client and update the versions file on this thread.
84
+ # Otherwise the workers race to lazily create the client and update
85
+ # the versions file concurrently, e.g. when the client was released
86
+ # after resolution and is being rebuilt for `bundle cache`.
87
+ compact_index_client.available?
88
+
76
89
  in_parallel(names) {|name| compact_index_client.info(name) }
77
90
  rescue TooManyRequestsError # rubygems.org is rate limiting us, slow down.
78
91
  @bundle_worker&.stop
@@ -9,6 +9,8 @@ module Bundler
9
9
  super
10
10
 
11
11
  @pool_size = Bundler.settings.installation_parallelization
12
+ ssl_ca_cert = Bundler.settings[:ssl_ca_cert]
13
+ @cert_files << ssl_ca_cert if ssl_ca_cert
12
14
  end
13
15
 
14
16
  def request(*args)
@@ -243,6 +243,10 @@ module Bundler
243
243
  fetchers.first.api_fetcher?
244
244
  end
245
245
 
246
+ def release_resolution_memory!
247
+ @fetchers&.each(&:release_resolution_memory!)
248
+ end
249
+
246
250
  def gem_remote_fetcher
247
251
  @gem_remote_fetcher ||= begin
248
252
  require_relative "fetcher/gem_remote_fetcher"
@@ -110,10 +110,49 @@ module Bundler
110
110
  end
111
111
 
112
112
  def install_with_worker
113
- installed_specs = {}
114
- enqueue_specs(installed_specs)
113
+ with_jobserver do
114
+ installed_specs = {}
115
+ enqueue_specs(installed_specs)
115
116
 
116
- process_specs(installed_specs) until finished_installing?
117
+ process_specs(installed_specs) until finished_installing?
118
+ end
119
+ end
120
+
121
+ def with_jobserver
122
+ # The jobserver hands tokens to child `make` processes through MAKEFLAGS
123
+ # using the GNU make `--jobserver-auth` protocol. nmake, the default make
124
+ # on mswin, instead reads MAKEFLAGS as bare option letters and aborts
125
+ # every native extension build with `fatal error U1065: invalid option
126
+ # '-'`. Skip the jobserver when nmake is in use. Other Windows toolchains
127
+ # such as mingw use GNU make and keep working through the inherited pipe.
128
+ return yield if nmake?
129
+
130
+ begin
131
+ r, w = IO.pipe
132
+ r.close_on_exec = false
133
+ w.close_on_exec = false
134
+ w.write("*" * @size)
135
+
136
+ old_makeflags = ENV["MAKEFLAGS"]
137
+ ENV["MAKEFLAGS"] = [old_makeflags, "--jobserver-auth=#{r.fileno},#{w.fileno}"].compact.join(" ")
138
+
139
+ yield
140
+ ensure
141
+ # Restore MAKEFLAGS before closing the pipe so a close failure can't
142
+ # leave the process with descriptors that point at a closed pipe.
143
+ old_makeflags ? ENV["MAKEFLAGS"] = old_makeflags : ENV.delete("MAKEFLAGS")
144
+
145
+ r&.close
146
+ w&.close
147
+ end
148
+ end
149
+
150
+ # Mirror how RubyGems' extension builder picks the make program so the
151
+ # jobserver is only set up when a GNU-compatible make will consume it.
152
+ def nmake?
153
+ make = ENV["MAKE"] || ENV["make"]
154
+ make ||= "nmake" if RUBY_PLATFORM.include?("mswin")
155
+ /\bnmake/i.match?(make.to_s)
117
156
  end
118
157
 
119
158
  def install_serially
@@ -195,7 +195,13 @@ module Bundler
195
195
  force = options[:force]
196
196
  local = options[:local] || options[:"prefer-local"]
197
197
  jobs = Bundler.settings.installation_parallelization
198
- spec_installations = ParallelInstaller.call(self, @definition.specs, jobs, standalone, force, local: local)
198
+ specs = @definition.specs
199
+ # Installing default gems may need the remote index again to cache
200
+ # their .gem files, so keep resolution memory around in that case.
201
+ # The bundler spec itself is excluded because it comes from the
202
+ # metadata source and never goes through that path.
203
+ @definition.release_resolution_memory! if specs.none? {|s| s.default_gem? && s.source.is_a?(Source::Rubygems) }
204
+ spec_installations = ParallelInstaller.call(self, specs, jobs, standalone, force, local: local)
199
205
  spec_installations.each do |installation|
200
206
  post_install_messages[installation.name] = installation.post_install_message if installation.has_post_install_message?
201
207
  end
@@ -160,18 +160,18 @@ module Bundler
160
160
 
161
161
  def wait_for_writtable_socket(socket, address, timeout)
162
162
  if IO.select(nil, [socket], nil, timeout)
163
- probe_writtable_socket(socket, address)
163
+ probe_writtable_socket(socket)
164
164
  else # TCP Handshake timed out, or there is something dropping packets
165
165
  false
166
166
  end
167
167
  end
168
168
 
169
- def probe_writtable_socket(socket, address)
170
- socket.connect_nonblock(address)
171
- rescue Errno::EISCONN
172
- true
173
- rescue StandardError # Connection failed
174
- false
169
+ def probe_writtable_socket(socket)
170
+ # Check the pending error on the socket rather than calling
171
+ # +connect_nonblock+ a second time. On BSD-based systems such as macOS a
172
+ # second connect returns +EISCONN+ even when the asynchronous connect
173
+ # failed, which would make a down mirror look reachable.
174
+ socket.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR).int == 0
175
175
  end
176
176
  end
177
177
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ module Plugin
5
+ # Stands in for a source handled by a plugin that is not loaded yet, so
6
+ # that the lockfile can still be parsed during the plugin install pass,
7
+ # and by external tools reading a lockfile without the plugin installed.
8
+ class UnloadedSource
9
+ include API::Source
10
+
11
+ # Unlike real plugin sources, where the handling class encodes the
12
+ # source type, all unloaded sources share this class, so the type must
13
+ # be compared explicitly.
14
+ def ==(other)
15
+ super && options["type"] == other.options["type"]
16
+ end
17
+
18
+ alias_method :eql?, :==
19
+
20
+ def hash
21
+ [super, options["type"]].hash
22
+ end
23
+ end
24
+ end
25
+ end
@@ -4,11 +4,12 @@ require_relative "plugin/api"
4
4
 
5
5
  module Bundler
6
6
  module Plugin
7
- autoload :DSL, File.expand_path("plugin/dsl", __dir__)
8
- autoload :Events, File.expand_path("plugin/events", __dir__)
9
- autoload :Index, File.expand_path("plugin/index", __dir__)
10
- autoload :Installer, File.expand_path("plugin/installer", __dir__)
11
- autoload :SourceList, File.expand_path("plugin/source_list", __dir__)
7
+ autoload :DSL, File.expand_path("plugin/dsl", __dir__)
8
+ autoload :Events, File.expand_path("plugin/events", __dir__)
9
+ autoload :Index, File.expand_path("plugin/index", __dir__)
10
+ autoload :Installer, File.expand_path("plugin/installer", __dir__)
11
+ autoload :SourceList, File.expand_path("plugin/source_list", __dir__)
12
+ autoload :UnloadedSource, File.expand_path("plugin/unloaded_source", __dir__)
12
13
 
13
14
  class MalformattedPlugin < PluginError; end
14
15
  class UndefinedCommandError < PluginError; end
@@ -199,9 +200,14 @@ module Bundler
199
200
  # @return [API::Source] the instance of the class that handles the source
200
201
  # type passed in locked_opts
201
202
  def from_lock(locked_opts)
203
+ opts = locked_opts.merge("uri" => locked_opts["remote"])
204
+ # use an inert placeholder when the plugin handling this source is not
205
+ # installed, so that the lockfile can still be parsed
206
+ return UnloadedSource.new(opts) unless source?(locked_opts["type"])
207
+
202
208
  src = source(locked_opts["type"])
203
209
 
204
- src.new(locked_opts.merge("uri" => locked_opts["remote"]))
210
+ src.new(opts)
205
211
  end
206
212
 
207
213
  # To be called via the API to register a hooks and corresponding block that
@@ -8,6 +8,7 @@ module Bundler
8
8
  attr_reader :packages, :requirements, :source_requirements, :locked_specs
9
9
 
10
10
  def initialize(source_requirements, dependencies, base, platforms, options)
11
+ @explicit_unlocks = options.delete(:explicit_unlocks) || []
11
12
  @source_requirements = source_requirements
12
13
  @locked_specs = options[:locked_specs]
13
14
 
@@ -43,6 +44,14 @@ module Bundler
43
44
  @packages[name]
44
45
  end
45
46
 
47
+ # Gems the user named on a `bundle update GEM` / `bundle lock --update GEM`
48
+ # command line. These are the only ones meant to move off their locked
49
+ # version, so cooldown keeps applying to them while every other locked gem
50
+ # stays exempt.
51
+ def explicitly_unlocked?(name)
52
+ @explicit_unlocks.include?(name)
53
+ end
54
+
46
55
  def base_requirements
47
56
  @base_requirements ||= build_base_requirements
48
57
  end
@@ -437,11 +437,31 @@ module Bundler
437
437
  def cooldown_excluded?(spec)
438
438
  return false unless spec.respond_to?(:created_at) && spec.created_at
439
439
  return false unless spec.respond_to?(:remote) && spec.remote
440
+ return false if locked_by_lockfile?(spec)
440
441
  days = spec.remote.effective_cooldown
441
442
  return false if days.nil? || days <= 0
442
443
  (cooldown_now - spec.created_at) < (days * 86_400)
443
444
  end
444
445
 
446
+ # A version already written to the lockfile has been adopted, and cooldown
447
+ # only governs the adoption of *new* versions, so it must never retract one
448
+ # the lockfile already pins. Keying this off the locked specs rather than the
449
+ # prevent-downgrade floor matters because that floor is absent on resolutions
450
+ # that re-pick a gem from scratch: the auxiliary full update run to compute
451
+ # `--update` targets, and the from-scratch retries after a conflict unlocks a
452
+ # gem. In those passes the locked version is the only candidate, so filtering
453
+ # it out makes an unrelated operation impossible whenever every published
454
+ # version matching the requirement sits inside the cooldown window.
455
+ #
456
+ # Gems named on a `bundle update GEM` command are the exception: the user
457
+ # asked to move them, so they stay subject to cooldown and a locked-but-fresh
458
+ # release is pushed back to an older one (or fails loudly when none exists).
459
+ def locked_by_lockfile?(spec)
460
+ return false unless defined?(@base) && @base
461
+ return false if @base.explicitly_unlocked?(spec.name)
462
+ @base.locked_specs[spec.name].any? {|locked| locked.version == spec.version }
463
+ end
464
+
445
465
  def cooldown_now
446
466
  @cooldown_now ||= Time.now
447
467
  end
@@ -4,6 +4,11 @@ require "rubygems/installer"
4
4
 
5
5
  module Bundler
6
6
  class RubyGemsGemInstaller < Gem::Installer
7
+ # Cap how many jobserver slots a single gem's `make` may grab so that one
8
+ # gem with many recipes doesn't starve the others sharing the pool. Beyond
9
+ # a handful of jobs the extra parallelism rarely pays off in practice.
10
+ MAX_JOBS_PER_GEM = 3
11
+
7
12
  def check_executable_overwrite(filename)
8
13
  # Bundler needs to install gems regardless of binstub overwriting
9
14
  end
@@ -101,10 +106,18 @@ module Bundler
101
106
  end
102
107
 
103
108
  def build_jobs
104
- Bundler.settings[:jobs] || super
109
+ @jobserver_read_io&.read_nonblock(MAX_JOBS_PER_GEM, @jobserver_tokens)
110
+ acquired_jobs = @jobserver_tokens.empty? ? nil : @jobserver_tokens.size
111
+
112
+ acquired_jobs || Bundler.settings[:jobs] || super
113
+ rescue IO::WaitReadable, EOFError
114
+ 1
105
115
  end
106
116
 
107
117
  def build_extensions
118
+ @jobserver_tokens = +""
119
+ @jobserver_read_io, @jobserver_write_io = connect_to_jobserver
120
+
108
121
  extension_cache_path = options[:bundler_extension_cache_path]
109
122
  extension_dir = spec.extension_dir
110
123
  unless extension_cache_path && extension_dir
@@ -128,6 +141,11 @@ module Bundler
128
141
  FileUtils.cp_r extension_dir, extension_cache_path
129
142
  end
130
143
  end
144
+ ensure
145
+ unless @jobserver_tokens.empty?
146
+ @jobserver_write_io.write(@jobserver_tokens)
147
+ @jobserver_write_io.flush
148
+ end
131
149
  end
132
150
 
133
151
  def spec
@@ -144,6 +162,21 @@ module Bundler
144
162
 
145
163
  private
146
164
 
165
+ def connect_to_jobserver
166
+ return unless ENV["MAKEFLAGS"]
167
+ # We append our own --jobserver-auth, so read the last one. Otherwise a
168
+ # parent jobserver's descriptors (e.g. `bundle install` run under
169
+ # `make -j`) would be picked up instead of the pool ParallelInstaller created.
170
+ read_fd, write_fd = ENV["MAKEFLAGS"].scan(/--jobserver-auth=(\d+),(\d+)/).last
171
+
172
+ return unless read_fd && write_fd
173
+
174
+ # Pass explicit modes. On POSIX, IO.new detects the descriptor's access
175
+ # mode, but on Windows it can't, so the write end would default to read
176
+ # mode and raise "IOError: not opened for writing" when releasing slots.
177
+ [IO.new(read_fd.to_i, "r", autoclose: false), IO.new(write_fd.to_i, "w", autoclose: false)]
178
+ end
179
+
147
180
  def prepare_extension_build(extension_dir)
148
181
  SharedHelpers.filesystem_access(extension_dir, :create) do
149
182
  FileUtils.mkdir_p extension_dir
@@ -144,6 +144,12 @@ module Bundler
144
144
  FileUtils.rm_rf(p)
145
145
  end
146
146
  git "clone", "--no-checkout", "--quiet", path.to_s, destination.to_s
147
+ # The copy is cloned from the local bare cache, which holds no Git LFS
148
+ # objects, so point origin back at the real remote and let git-lfs derive
149
+ # its endpoint from there when checking out. Use the credential-filtered
150
+ # URI to avoid persisting secrets in the copy's .git/config; auth is left
151
+ # to git's credential helper.
152
+ git "remote", "set-url", "origin", credential_filtered_uri, dir: destination
147
153
  File.chmod((File.stat(destination).mode | 0o777) & ~File.umask, destination)
148
154
  rescue Errno::EEXIST => e
149
155
  file_path = e.message[%r{.*?((?:[a-zA-Z]:)?/.*)}, 1]
@@ -11,7 +11,7 @@ module Bundler
11
11
  API_REQUEST_SIZE = 100
12
12
  REQUIRE_MUTEX = Mutex.new
13
13
 
14
- attr_accessor :remotes
14
+ attr_accessor :remotes, :remote_cooldowns
15
15
 
16
16
  def initialize(options = {})
17
17
  @options = options
@@ -25,6 +25,7 @@ module Bundler
25
25
  @checksum_store = Checksum::Store.new
26
26
  @gem_installers = {}
27
27
  @gem_installers_mutex = Mutex.new
28
+ @remote_specs_mutex = Mutex.new
28
29
 
29
30
  cooldown = options["cooldown"]
30
31
  Array(options["remotes"]).reverse_each {|r| add_remote(r, cooldown: cooldown) }
@@ -243,7 +244,7 @@ module Bundler
243
244
  def cached_built_in_gem(spec, local: false)
244
245
  cached_path = cached_gem(spec)
245
246
  if cached_path.nil? && !local
246
- remote_spec = remote_specs.search(spec).first
247
+ remote_spec = remote_spec_for(spec)
247
248
  if remote_spec
248
249
  cached_path = fetch_gem(remote_spec)
249
250
  spec.remote = remote_spec.remote
@@ -337,6 +338,12 @@ module Bundler
337
338
  @cached_specs = nil
338
339
  end
339
340
 
341
+ def release_resolution_memory!
342
+ @specs = nil
343
+ @remote_specs_mutex.synchronize { @remote_specs = nil }
344
+ @fetchers&.each(&:release_resolution_memory!)
345
+ end
346
+
340
347
  protected
341
348
 
342
349
  def remote_names
@@ -414,17 +421,30 @@ module Bundler
414
421
  end
415
422
 
416
423
  def remote_specs
417
- @remote_specs ||= Index.build do |idx|
418
- index_fetchers = fetchers - api_fetchers
424
+ @remote_specs ||= @remote_specs_mutex.synchronize do
425
+ @remote_specs ||= Index.build do |idx|
426
+ index_fetchers = fetchers - api_fetchers
419
427
 
420
- if index_fetchers.empty?
421
- fetch_names(api_fetchers, dependency_names, idx)
422
- else
423
- fetch_names(fetchers, nil, idx)
428
+ if index_fetchers.empty?
429
+ fetch_names(api_fetchers, dependency_names, idx)
430
+ else
431
+ fetch_names(fetchers, nil, idx)
432
+ end
424
433
  end
425
434
  end
426
435
  end
427
436
 
437
+ # Looks up a single spec in the remote sources, fetching only its own
438
+ # name when the full remote index is not already materialized.
439
+ def remote_spec_for(spec)
440
+ return remote_specs.search(spec).first if @remote_specs || api_fetchers.empty?
441
+
442
+ index = Index.build do |idx|
443
+ fetch_names(api_fetchers, [spec.name], idx)
444
+ end
445
+ index.search(spec).first
446
+ end
447
+
428
448
  def fetch_names(fetchers, dependency_names, index)
429
449
  fetchers.each do |f|
430
450
  if dependency_names
@@ -140,6 +140,10 @@ module Bundler
140
140
  rubygems_sources.each(&:clear_cache)
141
141
  end
142
142
 
143
+ def release_resolution_memory!
144
+ rubygems_sources.each(&:release_resolution_memory!)
145
+ end
146
+
143
147
  private
144
148
 
145
149
  def map_sources(replacement_sources)
@@ -169,6 +173,10 @@ module Bundler
169
173
  # locked sources never include credentials so always prefer remotes from the gemfile
170
174
  replacement_source.remotes = gemfile_source.remotes
171
175
 
176
+ # cooldowns are only ever declared in the Gemfile, so carry them over
177
+ # along with the remotes they apply to
178
+ replacement_source.remote_cooldowns = gemfile_source.remote_cooldowns
179
+
172
180
  yield replacement_source if block_given?
173
181
 
174
182
  replacement_source
@@ -47,7 +47,7 @@ Gem::Specification.new do |spec|
47
47
  # Uncomment to register a new dependency of your gem
48
48
  # spec.add_dependency "example-gem", "~> 1.0"
49
49
  <%- if config[:ext] == 'rust' -%>
50
- spec.add_dependency "rb_sys", "~> 0.9.91"
50
+ spec.add_dependency "rb_sys", "~> 0.9.128"
51
51
  <%- end -%>
52
52
  <%- if config[:ext] == 'go' -%>
53
53
  spec.add_dependency "go_gem", "~> 0.2"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "4.0.13".freeze
4
+ VERSION = "4.0.15".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= gem_version.segments.first
@@ -41,8 +41,9 @@ class Gem::Ext::Builder
41
41
  # nmake doesn't support parallel build
42
42
  unless is_nmake
43
43
  have_make_arguments = make_program.size > 1
44
+ n_jobs ||= 0
44
45
 
45
- if !have_make_arguments && !ENV["MAKEFLAGS"] && n_jobs
46
+ if !have_make_arguments && n_jobs > 1 && !ENV["MAKEFLAGS"]&.match(/-j\d*(\s|\Z)/)
46
47
  make_program << "-j#{n_jobs}"
47
48
  end
48
49
  end
@@ -294,7 +294,7 @@ class Gem::Installer
294
294
 
295
295
  File.chmod(dir_mode, gem_dir) if dir_mode
296
296
 
297
- say spec.post_install_message if options[:post_install_message] && !spec.post_install_message.nil?
297
+ say clean_text(spec.post_install_message.to_s) if options[:post_install_message] && !spec.post_install_message.nil?
298
298
 
299
299
  Gem::Specification.add_spec(spec) unless @install_dir
300
300
 
@@ -707,6 +707,18 @@ class Gem::Installer
707
707
  if spec.dependencies.any? {|dep| dep.name =~ /(?:\R|[<>])/ }
708
708
  raise Gem::InstallError, "#{spec} has an invalid dependencies"
709
709
  end
710
+
711
+ if spec.executables.any? {|name| !name.is_a?(String) || name != File.basename(name) || /\A\.\.?\z|\R/.match?(name) }
712
+ raise Gem::InstallError, "#{spec} has an invalid executable"
713
+ end
714
+
715
+ raise Gem::InstallError, "#{spec} has an invalid bindir" unless spec.bindir.is_a?(String)
716
+
717
+ expanded_gem_dir = File.expand_path(gem_dir)
718
+ expanded_bindir = File.expand_path(File.join(gem_dir, spec.bindir))
719
+ unless expanded_bindir == expanded_gem_dir || expanded_bindir.start_with?("#{expanded_gem_dir}/")
720
+ raise Gem::InstallError, "#{spec} has an invalid bindir"
721
+ end
710
722
  end
711
723
 
712
724
  ##
@@ -715,6 +727,7 @@ class Gem::Installer
715
727
  def app_script_text(bin_file_name)
716
728
  # NOTE: that the `load` lines cannot be indented, as old RG versions match
717
729
  # against the beginning of the line
730
+ escaped_bin_file_name = bin_file_name.gsub(/[\\']/) {|c| "\\#{c}" }
718
731
  <<~TEXT
719
732
  #{shebang bin_file_name}
720
733
  #
@@ -738,9 +751,9 @@ class Gem::Installer
738
751
  end
739
752
 
740
753
  if Gem.respond_to?(:activate_and_load_bin_path)
741
- Gem.activate_and_load_bin_path('#{spec.name}', '#{bin_file_name}', version)
754
+ Gem.activate_and_load_bin_path('#{spec.name}', '#{escaped_bin_file_name}', version)
742
755
  else
743
- load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version)
756
+ load Gem.activate_bin_path('#{spec.name}', '#{escaped_bin_file_name}', version)
744
757
  end
745
758
  TEXT
746
759
  end
@@ -161,7 +161,7 @@ class Gem::Package
161
161
  return super unless gem.start
162
162
  return super unless gem.start.include? "MD5SUM ="
163
163
 
164
- Gem::Package::Old.new gem
164
+ Gem::Package::Old.new gem, security_policy
165
165
  end
166
166
 
167
167
  ##
@@ -61,7 +61,7 @@ class Gem::Request
61
61
  if Gem.configuration.ssl_client_cert
62
62
  pem = File.read Gem.configuration.ssl_client_cert
63
63
  connection.cert = OpenSSL::X509::Certificate.new pem
64
- connection.key = OpenSSL::PKey::RSA.new pem
64
+ connection.key = OpenSSL::PKey.read pem
65
65
  end
66
66
 
67
67
  store.set_default_paths
@@ -28,6 +28,8 @@ module Gem
28
28
 
29
29
  def initialize(io)
30
30
  @io = io
31
+ @object_links = {}
32
+ @symbol_links = {}
31
33
  end
32
34
 
33
35
  def read!
@@ -191,7 +193,7 @@ module Gem
191
193
 
192
194
  def read_symbol_link
193
195
  offset = read_integer
194
- Elements::SymbolLink.new(offset)
196
+ @symbol_links[offset] ||= Elements::SymbolLink.new(offset)
195
197
  end
196
198
 
197
199
  def read_user_marshal
@@ -200,43 +202,9 @@ module Gem
200
202
  Elements::UserMarshal.new(name, data)
201
203
  end
202
204
 
203
- # profiling bundle install --full-index shows that
204
- # offset 6 is by far the most common object link,
205
- # so we special case it to avoid allocating a new
206
- # object a third of the time.
207
- # the following are all the object links that
208
- # appear more than 10000 times in my profiling
209
-
210
- OBJECT_LINKS = {
211
- 6 => Elements::ObjectLink.new(6).freeze,
212
- 30 => Elements::ObjectLink.new(30).freeze,
213
- 81 => Elements::ObjectLink.new(81).freeze,
214
- 34 => Elements::ObjectLink.new(34).freeze,
215
- 38 => Elements::ObjectLink.new(38).freeze,
216
- 50 => Elements::ObjectLink.new(50).freeze,
217
- 91 => Elements::ObjectLink.new(91).freeze,
218
- 42 => Elements::ObjectLink.new(42).freeze,
219
- 46 => Elements::ObjectLink.new(46).freeze,
220
- 150 => Elements::ObjectLink.new(150).freeze,
221
- 100 => Elements::ObjectLink.new(100).freeze,
222
- 104 => Elements::ObjectLink.new(104).freeze,
223
- 108 => Elements::ObjectLink.new(108).freeze,
224
- 242 => Elements::ObjectLink.new(242).freeze,
225
- 246 => Elements::ObjectLink.new(246).freeze,
226
- 139 => Elements::ObjectLink.new(139).freeze,
227
- 143 => Elements::ObjectLink.new(143).freeze,
228
- 114 => Elements::ObjectLink.new(114).freeze,
229
- 308 => Elements::ObjectLink.new(308).freeze,
230
- 200 => Elements::ObjectLink.new(200).freeze,
231
- 54 => Elements::ObjectLink.new(54).freeze,
232
- 62 => Elements::ObjectLink.new(62).freeze,
233
- 1_286_245 => Elements::ObjectLink.new(1_286_245).freeze,
234
- }.freeze
235
- private_constant :OBJECT_LINKS
236
-
237
205
  def read_object_link
238
206
  offset = read_integer
239
- OBJECT_LINKS[offset] || Elements::ObjectLink.new(offset)
207
+ @object_links[offset] ||= Elements::ObjectLink.new(offset)
240
208
  end
241
209
 
242
210
  EMPTY_HASH = Elements::Hash.new([].freeze).freeze
data/lib/rubygems/text.rb CHANGED
@@ -8,7 +8,16 @@ module Gem::Text
8
8
  # Remove any non-printable characters and make the text suitable for
9
9
  # printing.
10
10
  def clean_text(text)
11
- text.gsub(/[\000-\b\v-\f\016-\037\177]/, ".")
11
+ text = text.gsub(/[\000-\b\v-\f\016-\037\177]/, ".")
12
+
13
+ # Match C1 control characters (U+0080-U+009F) as codepoints. This requires
14
+ # a valid UTF-8 string so the regexp does not split a multibyte sequence;
15
+ # strings in other encodings are left unchanged.
16
+ if text.encoding == Encoding::UTF_8 && text.valid_encoding?
17
+ text = text.gsub(/[\u0080-\u009f]/, ".")
18
+ end
19
+
20
+ text
12
21
  end
13
22
 
14
23
  def truncate_text(text, description, max_length = 100_000)
data/lib/rubygems.rb CHANGED
@@ -9,7 +9,7 @@
9
9
  require "rbconfig"
10
10
 
11
11
  module Gem
12
- VERSION = "4.0.13"
12
+ VERSION = "4.0.15"
13
13
  end
14
14
 
15
15
  require_relative "rubygems/defaults"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-update
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.13
4
+ version: 4.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
@@ -250,6 +250,7 @@ files:
250
250
  - bundler/lib/bundler/plugin/installer/path.rb
251
251
  - bundler/lib/bundler/plugin/installer/rubygems.rb
252
252
  - bundler/lib/bundler/plugin/source_list.rb
253
+ - bundler/lib/bundler/plugin/unloaded_source.rb
253
254
  - bundler/lib/bundler/process_lock.rb
254
255
  - bundler/lib/bundler/remote_specification.rb
255
256
  - bundler/lib/bundler/resolver.rb
@@ -724,7 +725,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
724
725
  - !ruby/object:Gem::Version
725
726
  version: '0'
726
727
  requirements: []
727
- rubygems_version: 4.0.10
728
+ rubygems_version: 4.0.13
728
729
  specification_version: 4
729
730
  summary: RubyGems is a package management framework for Ruby. This gem is downloaded
730
731
  and installed by `gem update --system`, so that the `gem` CLI can update itself.