rubygems-update 4.0.20 → 4.0.22

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/Manifest.txt +0 -2
  4. data/bundler/CHANGELOG.md +30 -0
  5. data/bundler/bundler.gemspec +1 -1
  6. data/bundler/lib/bundler/build_metadata.rb +2 -2
  7. data/bundler/lib/bundler/cli/platform.rb +15 -1
  8. data/bundler/lib/bundler/cli/update.rb +1 -1
  9. data/bundler/lib/bundler/cli.rb +19 -7
  10. data/bundler/lib/bundler/definition.rb +12 -2
  11. data/bundler/lib/bundler/fetcher/downloader.rb +10 -1
  12. data/bundler/lib/bundler/installer.rb +4 -0
  13. data/bundler/lib/bundler/man/bundle-lock.1 +2 -2
  14. data/bundler/lib/bundler/man/bundle-lock.1.ronn +4 -3
  15. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  16. data/bundler/lib/bundler/man/bundle-outdated.1.ronn +1 -1
  17. data/bundler/lib/bundler/man/bundle-update.1 +3 -3
  18. data/bundler/lib/bundler/man/bundle-update.1.ronn +5 -3
  19. data/bundler/lib/bundler/self_manager.rb +15 -9
  20. data/bundler/lib/bundler/source/git/git_proxy.rb +9 -1
  21. data/bundler/lib/bundler/source/git.rb +6 -4
  22. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  23. data/bundler/lib/bundler/version.rb +1 -1
  24. data/bundler/lib/bundler.rb +1 -3
  25. data/lib/rubygems/commands/exec_command.rb +3 -0
  26. data/lib/rubygems/ext/builder.rb +7 -2
  27. data/lib/rubygems/gemcutter_utilities/webauthn_listener.rb +9 -0
  28. data/lib/rubygems/installer.rb +4 -0
  29. data/lib/rubygems/package.rb +1 -1
  30. data/lib/rubygems/uninstaller.rb +1 -0
  31. data/lib/rubygems/vendor/net-http/lib/net/http.rb +24 -2
  32. data/lib/rubygems.rb +1 -1
  33. metadata +1 -3
  34. data/lib/rubygems/vendor/resolv/COPYING +0 -56
  35. data/lib/rubygems/vendor/resolv/lib/resolv.rb +0 -3499
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c5b9e451752787719ea243e41b423937313b296fe80fcdb9e2278c47bce0311
4
- data.tar.gz: 40407c5dda968a596b10a34cfe59e6884ed03a2224c43934aaf1b2dc86c7d0f3
3
+ metadata.gz: 749ce900ad671da4cc10f224bc056fd01abb570ad1ea631796dad9f33025b538
4
+ data.tar.gz: 71a19e66013da25a69f73e12f96251f8615463e9f805fbd4be14003ff7f2395a
5
5
  SHA512:
6
- metadata.gz: a98a6944def23e28a4f45a8be9d1d7fa36b488cf1add3e542ffae3ca9ace3adfde5499ddd36a0e1a15ad0baf363ab05509d4bcfd7d714d4209c6fcba1dc2a6b2
7
- data.tar.gz: 5f399d26a853785b4ead62f67c12f84f7225af52cb700fb39fd50e8895e481d91c667b51d9b2c8df925f3c46477044d9704039c86a67bcdaeaff80c529f97f64
6
+ metadata.gz: 0e2f312ea9515fbabdd056db9d9233f8557243c4060cb8ebb15e1394c55624b6d23eaadfd40a512baca8ea70ec1dd1c5e521744d532ce3ef3c256d7e133356ed
7
+ data.tar.gz: d961561440e32ad0f6768f2db8a2a73a098df218219c13b3d66dd3b7c013fb7c75fe71ffb8a9ecd52901525e239ef92fb28a897ea317ef337034525029afa070
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.22 / 2026-09-30
4
+
5
+ ### Enhancements:
6
+
7
+ * Add --source option to gem exec command. Pull request [#9765](https://github.com/ruby/rubygems/pull/9765) by Akshay Birajdar and Akshay Birajdar
8
+ * Keep credentials on redirects only within the same origin. Pull request [#9909](https://github.com/ruby/rubygems/pull/9909) by Hiroshi SHIBATA
9
+ * Validate the version field in Gem::Installer#verify_spec. Pull request [#9890](https://github.com/ruby/rubygems/pull/9890) by Hiroshi SHIBATA
10
+ * Installs bundler 4.0.22 as a default gem.
11
+
12
+ ### Bug fixes:
13
+
14
+ * Remove the build_info file on uninstall and stop gem build from logging unknown extensions. Pull request [#9894](https://github.com/ruby/rubygems/pull/9894) by Hiroshi SHIBATA
15
+
16
+ ## 4.0.21 / 2026-09-16
17
+
18
+ ### Enhancements:
19
+
20
+ * Stop vendoring resolv for two regexps. Pull request [#9877](https://github.com/ruby/rubygems/pull/9877) by Hiroshi SHIBATA
21
+ * Normalize absolute symlink targets during gem extraction. Pull request [#9860](https://github.com/ruby/rubygems/pull/9860) by Hiroshi SHIBATA
22
+ * Installs bundler 4.0.21 as a default gem.
23
+
3
24
  ## 4.0.20 / 2026-09-02
4
25
 
5
26
  ### Enhancements:
data/Manifest.txt CHANGED
@@ -578,8 +578,6 @@ lib/rubygems/vendor/optparse/lib/optparse/shellwords.rb
578
578
  lib/rubygems/vendor/optparse/lib/optparse/time.rb
579
579
  lib/rubygems/vendor/optparse/lib/optparse/uri.rb
580
580
  lib/rubygems/vendor/optparse/lib/optparse/version.rb
581
- lib/rubygems/vendor/resolv/COPYING
582
- lib/rubygems/vendor/resolv/lib/resolv.rb
583
581
  lib/rubygems/vendor/securerandom/COPYING
584
582
  lib/rubygems/vendor/securerandom/lib/securerandom.rb
585
583
  lib/rubygems/vendor/timeout/COPYING
data/bundler/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.22 / 2026-09-30
4
+
5
+ ### Enhancements:
6
+
7
+ * Report the effective platform in `bundle platform`. Pull request [#9898](https://github.com/ruby/rubygems/pull/9898) by Islam Elsayed
8
+ * Keep credentials on redirects only within the same origin. Pull request [#9909](https://github.com/ruby/rubygems/pull/9909) by Hiroshi SHIBATA
9
+ * Update Magnus version in Rust extension gem template. Pull request [#9904](https://github.com/ruby/rubygems/pull/9904) by Mat Sadler and Hiroshi SHIBATA
10
+
11
+ ### Bug fixes:
12
+
13
+ * Stop `Bundler.bin_path` creating the directory it reports. Pull request [#9887](https://github.com/ruby/rubygems/pull/9887) by Islam Elsayed and Hiroshi SHIBATA
14
+ * Look up `bundler-<command>` executables only in PATH. Pull request [#9874](https://github.com/ruby/rubygems/pull/9874) by Hiroshi SHIBATA
15
+
16
+ ### Documentation:
17
+
18
+ * Describe `--major` as preferring the latest major version. Pull request [#9891](https://github.com/ruby/rubygems/pull/9891) by Hiroshi SHIBATA
19
+
20
+ ## 4.0.21 / 2026-09-16
21
+
22
+ ### Enhancements:
23
+
24
+ * Don't update bundler to a prerelease unless asked for one. Pull request [#9869](https://github.com/ruby/rubygems/pull/9869) by Hiroshi SHIBATA
25
+ * Reject Bundler redirects that downgrade https to http. Pull request [#9859](https://github.com/ruby/rubygems/pull/9859) by Hiroshi SHIBATA
26
+
27
+ ### Bug fixes:
28
+
29
+ * Support `safe.bareRepository=explicit` in git sources. Pull request [#9876](https://github.com/ruby/rubygems/pull/9876) by Hiroshi SHIBATA
30
+ * Stop resolving locally for empty CHECKSUMS entries. Pull request [#9862](https://github.com/ruby/rubygems/pull/9862) by Hiroshi SHIBATA
31
+ * Expand the git source gemspec path before the chdir. Pull request [#9845](https://github.com/ruby/rubygems/pull/9845) by Hiroshi SHIBATA
32
+
3
33
  ## 4.0.20 / 2026-09-02
4
34
 
5
35
  ### Enhancements:
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.metadata = {
26
26
  "bug_tracker_uri" => "https://github.com/ruby/rubygems/issues?q=is%3Aopen+is%3Aissue+label%3ABundler",
27
- "changelog_uri" => "https://github.com/ruby/rubygems/blob/master/CHANGELOG-bundler.md",
27
+ "changelog_uri" => "https://github.com/ruby/rubygems/blob/master/CHANGELOG.md",
28
28
  "homepage_uri" => "https://bundler.io/",
29
29
  "source_code_uri" => "https://github.com/ruby/rubygems",
30
30
  }
@@ -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-09-02".freeze
8
- @git_commit_sha = "7f2502dc32b".freeze
7
+ @built_at = "2026-09-30".freeze
8
+ @git_commit_sha = "ff2bd50".freeze
9
9
  # end ivars
10
10
 
11
11
  # A hash representation of the build metadata.
@@ -25,7 +25,7 @@ module Bundler
25
25
  else
26
26
  platforms = Bundler.definition.platforms.map {|p| "* #{p}" }
27
27
 
28
- output << "Your platform is: #{Gem::Platform.local}"
28
+ output << platform_info
29
29
  output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
30
30
 
31
31
  if ruby_version
@@ -44,5 +44,19 @@ module Bundler
44
44
 
45
45
  Bundler.ui.info output.join("\n\n")
46
46
  end
47
+
48
+ private
49
+
50
+ def platform_info
51
+ info = "Your platform is: #{Gem::Platform.local}"
52
+ return info if Bundler.local_platform == Gem::Platform.local
53
+
54
+ info + "\nHowever, your effective platform is: #{Bundler.local_platform} " \
55
+ "(because force_ruby_platform is #{force_ruby_platform_origin})"
56
+ end
57
+
58
+ def force_ruby_platform_origin
59
+ Bundler.settings.pretty_values_for(:force_ruby_platform).first.sub(/\ASet /, "set ")
60
+ end
47
61
  end
48
62
  end
@@ -13,7 +13,7 @@ module Bundler
13
13
 
14
14
  update_bundler = options[:bundler]
15
15
 
16
- Bundler.self_manager.update_bundler_and_restart_with_it_if_needed(update_bundler) if update_bundler
16
+ Bundler.self_manager.update_bundler_and_restart_with_it_if_needed(update_bundler, pre: options[:pre]) if update_bundler
17
17
 
18
18
  Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.settings[:plugins]
19
19
 
@@ -177,7 +177,7 @@ module Bundler
177
177
  else
178
178
  puts File.read("#{man_path}/#{File.basename(man_page)}.ronn")
179
179
  end
180
- elsif command_path = Bundler.which("bundler-#{cli}")
180
+ elsif command_path = self.class.bundler_command_path(cli)
181
181
  Kernel.exec(command_path, "--help")
182
182
  else
183
183
  super
@@ -189,11 +189,23 @@ module Bundler
189
189
  return Bundler::Plugin.exec_command(command, ARGV[1..-1])
190
190
  end
191
191
 
192
- return super unless command_path = Bundler.which("bundler-#{command}")
192
+ return super unless command_path = bundler_command_path(command)
193
193
 
194
194
  Kernel.exec(command_path, *ARGV[1..-1])
195
195
  end
196
196
 
197
+ # Only PATH is searched, unlike Bundler.which, which also finds a file in
198
+ # the current directory and returns a bare name that Kernel.exec cannot run.
199
+ def self.bundler_command_path(command)
200
+ ENV.fetch("PATH", "").split(File::PATH_SEPARATOR).each do |path|
201
+ path = path[1..-2] if path.start_with?('"') && path.end_with?('"')
202
+ command_path = Bundler.find_executable(File.expand_path("bundler-#{command}", path))
203
+ return command_path if command_path
204
+ end
205
+
206
+ nil
207
+ end
208
+
197
209
  desc "init [OPTIONS]", "Generates a Gemfile into the current working directory"
198
210
  long_desc <<-D
199
211
  Init generates a default Gemfile in the current working directory. When adding a
@@ -317,10 +329,10 @@ module Bundler
317
329
  method_option "source", type: :array, banner: "Update a specific source (and all gems associated with it)"
318
330
  method_option "force", type: :boolean, aliases: "--redownload", banner: "Force reinstalling every gem, even if already installed"
319
331
  method_option "ruby", type: :boolean, banner: "Update ruby specified in Gemfile.lock"
320
- method_option "bundler", type: :string, lazy_default: "> 0.a", banner: "Update the locked version of bundler"
332
+ method_option "bundler", type: :string, lazy_default: ">= #{Bundler::VERSION}", banner: "Update the locked version of bundler"
321
333
  method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
322
334
  method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
323
- method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
335
+ method_option "major", type: :boolean, banner: "Prefer updating to latest major version (default)"
324
336
  method_option "pre", type: :boolean, banner: "Always choose the highest allowed version when updating gems, regardless of prerelease status"
325
337
  method_option "strict", type: :boolean, banner: "Do not allow any gem to be updated past latest --patch | --minor | --major"
326
338
  method_option "conservative", type: :boolean, banner: "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
@@ -431,7 +443,7 @@ module Bundler
431
443
  method_option "filter-strict", type: :boolean, aliases: "--strict", banner: "Only list newer versions allowed by your Gemfile requirements"
432
444
  method_option "update-strict", type: :boolean, banner: "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
433
445
  method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
434
- method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
446
+ method_option "major", type: :boolean, banner: "Prefer updating to latest major version (default)"
435
447
  method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
436
448
  method_option "filter-major", type: :boolean, banner: "Only list major newer versions"
437
449
  method_option "filter-minor", type: :boolean, banner: "Only list minor newer versions"
@@ -638,11 +650,11 @@ module Bundler
638
650
  method_option "normalize-platforms", type: :boolean, default: false, banner: "Normalize lockfile platforms"
639
651
  method_option "patch", type: :boolean, banner: "If updating, prefer updating only to next patch version"
640
652
  method_option "minor", type: :boolean, banner: "If updating, prefer updating only to next minor version"
641
- method_option "major", type: :boolean, banner: "If updating, prefer updating to next major version (default)"
653
+ method_option "major", type: :boolean, banner: "If updating, prefer updating to latest major version (default)"
642
654
  method_option "pre", type: :boolean, banner: "If updating, always choose the highest allowed version, regardless of prerelease status"
643
655
  method_option "strict", type: :boolean, banner: "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
644
656
  method_option "conservative", type: :boolean, banner: "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
645
- method_option "bundler", type: :string, lazy_default: "> 0.a", banner: "Update the locked version of bundler"
657
+ method_option "bundler", type: :string, lazy_default: ">= #{Bundler::VERSION}", banner: "Update the locked version of bundler"
646
658
  method_option "cooldown", type: :numeric, banner: "Only consider gem versions published at least N days ago. Use 0 to disable."
647
659
  def lock
648
660
  require_relative "cli/lock"
@@ -192,7 +192,7 @@ module Bundler
192
192
 
193
193
  sources.cached!
194
194
 
195
- if options[:add_checksums] || (!options[:local] && install_needed?)
195
+ if options[:add_checksums] || (!options[:local] && (install_needed? || @locked_spec_with_empty_checksums))
196
196
  sources.remote!
197
197
  true
198
198
  else
@@ -639,7 +639,7 @@ module Bundler
639
639
  @missing_lockfile_dep ||
640
640
  @unlocking_bundler ||
641
641
  @locked_spec_with_missing_checksums ||
642
- @locked_spec_with_empty_checksums ||
642
+ empty_checksums_actionable? ||
643
643
  @locked_spec_with_missing_deps ||
644
644
  @locked_spec_with_invalid_deps
645
645
  end
@@ -648,6 +648,16 @@ module Bundler
648
648
  unlocking? || something_changed?
649
649
  end
650
650
 
651
+ # Only a remote fetch can fill an empty CHECKSUMS entry, so it justifies a
652
+ # resolution only when one is coming. Resolving locally for it would repeat
653
+ # on every `Bundler.setup` without changing the lockfile. Frozen mode still
654
+ # has to refuse the entry.
655
+ def empty_checksums_actionable?
656
+ return false unless @locked_spec_with_empty_checksums
657
+
658
+ Bundler.frozen_bundle? || !sources.local_mode?
659
+ end
660
+
651
661
  def should_add_extra_platforms?
652
662
  !lockfile_exists? && Bundler::MatchPlatform.generic_local_platform_is_ruby? && !Bundler.settings[:force_ruby_platform]
653
663
  end
@@ -46,7 +46,12 @@ module Bundler
46
46
  response
47
47
  when Gem::Net::HTTPRedirection
48
48
  new_uri = Gem::URI.parse(response["location"])
49
- if new_uri.host == uri.host
49
+ # Following a downgrade would put the credentials this request carries
50
+ # on a plaintext connection, so refuse it like Gem::RemoteFetcher does.
51
+ if https?(uri) && !https?(new_uri)
52
+ raise HTTPError, "Redirecting to a non-https URI is not allowed: #{URICredentialsFilter.credential_filtered_uri(new_uri)}"
53
+ end
54
+ if [new_uri.scheme, new_uri.host, new_uri.port] == [uri.scheme, uri.host, uri.port]
50
55
  new_uri.user = uri.user
51
56
  new_uri.password = uri.password
52
57
  end
@@ -105,6 +110,10 @@ module Bundler
105
110
 
106
111
  private
107
112
 
113
+ def https?(uri)
114
+ uri.scheme&.casecmp("https")&.zero?
115
+ end
116
+
108
117
  def validate_uri_scheme!(uri)
109
118
  return if /\Ahttps?\z/.match?(uri.scheme)
110
119
  raise InvalidOption,
@@ -127,6 +127,8 @@ module Bundler
127
127
  template_path = File.expand_path("templates/Executable", __dir__)
128
128
  template = File.read(template_path)
129
129
 
130
+ Bundler.mkdir_p(bin_path)
131
+
130
132
  exists = []
131
133
  spec.executables.each do |executable|
132
134
  binstub_path = "#{bin_path}/#{executable}"
@@ -173,6 +175,8 @@ module Bundler
173
175
  ruby_command = Thor::Util.ruby_command
174
176
  ruby_command = ruby_command
175
177
 
178
+ Bundler.mkdir_p(bin_path)
179
+
176
180
  spec.executables.each do |executable|
177
181
  next if executable == "bundle"
178
182
  executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
@@ -13,7 +13,7 @@ Lock the gems specified in Gemfile\.
13
13
  Ignores the existing lockfile\. Resolve then updates lockfile\. Taking a list of gems or updating all gems if no list is given\.
14
14
  .TP
15
15
  \fB\-\-bundler[=BUNDLER]\fR
16
- Update the locked version of bundler to the given version or the latest version if no version is given\.
16
+ Update the locked version of bundler\. BUNDLER can be a version such as \fB4\.0\.20\fR, or a requirement such as \fB"> 0\.a"\fR\. With no argument, update to the latest released version, which never selects a prerelease\.
17
17
  .TP
18
18
  \fB\-\-local\fR
19
19
  Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems' cache or in \fBvendor/cache\fR\. Note that if a appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
@@ -49,7 +49,7 @@ If updating, prefer updating only to next patch version\.
49
49
  If updating, prefer updating only to next minor version\.
50
50
  .TP
51
51
  \fB\-\-major\fR
52
- If updating, prefer updating to next major version (default)\.
52
+ If updating, prefer updating to latest major version (default)\.
53
53
  .TP
54
54
  \fB\-\-pre\fR
55
55
  If updating, always choose the highest allowed version, regardless of prerelease status\.
@@ -33,8 +33,9 @@ Lock the gems specified in Gemfile.
33
33
  of gems or updating all gems if no list is given.
34
34
 
35
35
  * `--bundler[=BUNDLER]`:
36
- Update the locked version of bundler to the given version or the latest
37
- version if no version is given.
36
+ Update the locked version of bundler. BUNDLER can be a version such as
37
+ `4.0.20`, or a requirement such as `"> 0.a"`. With no argument, update to the
38
+ latest released version, which never selects a prerelease.
38
39
 
39
40
  * `--local`:
40
41
  Do not attempt to connect to `rubygems.org`. Instead, Bundler will use the
@@ -74,7 +75,7 @@ Lock the gems specified in Gemfile.
74
75
  If updating, prefer updating only to next minor version.
75
76
 
76
77
  * `--major`:
77
- If updating, prefer updating to next major version (default).
78
+ If updating, prefer updating to latest major version (default).
78
79
 
79
80
  * `--pre`:
80
81
  If updating, always choose the highest allowed version, regardless of prerelease status.
@@ -37,7 +37,7 @@ List gems organized by groups\.
37
37
  Prefer updating only to next minor version\.
38
38
  .TP
39
39
  \fB\-\-major\fR
40
- Prefer updating to next major version (default)\.
40
+ Prefer updating to latest major version (default)\.
41
41
  .TP
42
42
  \fB\-\-patch\fR
43
43
  Prefer updating only to next patch version\.
@@ -55,7 +55,7 @@ are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
55
55
  Prefer updating only to next minor version.
56
56
 
57
57
  * `--major`:
58
- Prefer updating to next major version (default).
58
+ Prefer updating to latest major version (default).
59
59
 
60
60
  * `--patch`:
61
61
  Prefer updating only to next patch version.
@@ -27,7 +27,7 @@ Do not attempt to fetch gems remotely and use the gem cache instead\.
27
27
  Update the locked version of Ruby to the current version of Ruby\.
28
28
  .TP
29
29
  \fB\-\-bundler[=BUNDLER]\fR
30
- Update the locked version of bundler to the invoked bundler version\.
30
+ Update the locked version of bundler\. BUNDLER can be a version such as \fB4\.0\.20\fR, or a requirement such as \fB"> 0\.a"\fR\. With no argument, update to the latest released version, which never selects a prerelease\.
31
31
  .TP
32
32
  \fB\-\-force\fR, \fB\-\-redownload\fR
33
33
  Force reinstalling every gem, even if already installed\.
@@ -54,7 +54,7 @@ Prefer updating only to next patch version\.
54
54
  Prefer updating only to next minor version\.
55
55
  .TP
56
56
  \fB\-\-major\fR
57
- Prefer updating to next major version (default)\.
57
+ Prefer updating to latest major version (default)\.
58
58
  .TP
59
59
  \fB\-\-pre\fR
60
60
  Always choose the highest allowed version, regardless of prerelease status\.
@@ -175,7 +175,7 @@ Prefer updating only to next patch version\.
175
175
  Prefer updating only to next minor version\.
176
176
  .TP
177
177
  \fB\-\-major\fR
178
- Prefer updating to next major version (default)\.
178
+ Prefer updating to latest major version (default)\.
179
179
  .TP
180
180
  \fB\-\-strict\fR
181
181
  Do not allow any gem to be updated past latest \fB\-\-patch\fR | \fB\-\-minor\fR | \fB\-\-major\fR\.
@@ -53,7 +53,9 @@ gem.
53
53
  Update the locked version of Ruby to the current version of Ruby.
54
54
 
55
55
  * `--bundler[=BUNDLER]`:
56
- Update the locked version of bundler to the invoked bundler version.
56
+ Update the locked version of bundler. BUNDLER can be a version such as
57
+ `4.0.20`, or a requirement such as `"> 0.a"`. With no argument, update to the
58
+ latest released version, which never selects a prerelease.
57
59
 
58
60
  * `--force`, `--redownload`:
59
61
  Force reinstalling every gem, even if already installed.
@@ -81,7 +83,7 @@ gem.
81
83
  Prefer updating only to next minor version.
82
84
 
83
85
  * `--major`:
84
- Prefer updating to next major version (default).
86
+ Prefer updating to latest major version (default).
85
87
 
86
88
  * `--pre`:
87
89
  Always choose the highest allowed version, regardless of prerelease status.
@@ -236,7 +238,7 @@ versions are resolved. One of the following options can be used: `--patch`,
236
238
  Prefer updating only to next minor version.
237
239
 
238
240
  * `--major`:
239
- Prefer updating to next major version (default).
241
+ Prefer updating to latest major version (default).
240
242
 
241
243
  * `--strict`:
242
244
  Do not allow any gem to be updated past latest `--patch` | `--minor` | `--major`.
@@ -30,8 +30,8 @@ module Bundler
30
30
  install_and_restart_with(restart_version)
31
31
  end
32
32
 
33
- def update_bundler_and_restart_with_it_if_needed(target)
34
- spec = resolve_update_version_from(target)
33
+ def update_bundler_and_restart_with_it_if_needed(target, pre: false)
34
+ spec = resolve_update_version_from(target, pre: pre)
35
35
  return unless spec
36
36
 
37
37
  version = spec.version
@@ -108,9 +108,9 @@ module Bundler
108
108
  lockfile_version
109
109
  end
110
110
 
111
- def resolve_update_version_from(target)
111
+ def resolve_update_version_from(target, pre: false)
112
112
  requirement = Gem::Requirement.new(target)
113
- update_candidate = find_latest_matching_spec(requirement)
113
+ update_candidate = find_latest_matching_spec(requirement, pre: pre)
114
114
 
115
115
  if update_candidate.nil?
116
116
  raise InvalidOption, "The `bundle update --bundler` target version (#{target}) does not exist"
@@ -137,18 +137,24 @@ module Bundler
137
137
  end
138
138
  end
139
139
 
140
- def find_latest_matching_spec(requirement)
140
+ def find_latest_matching_spec(requirement, pre: false)
141
141
  Bundler.configure
142
- local_result = find_latest_matching_spec_from_collection(local_specs, requirement)
142
+ # A bare `bundle update --bundler` must stay on releases, like `gem update
143
+ # --system`, so only `--pre` or a prerelease requirement opts into one.
144
+ allow_prerelease = pre || requirement.prerelease?
145
+
146
+ local_result = find_latest_matching_spec_from_collection(local_specs, requirement, allow_prerelease)
143
147
  return local_result if local_result && requirement.specific?
144
148
 
145
- remote_result = find_latest_matching_spec_from_collection(remote_specs, requirement)
149
+ remote_result = find_latest_matching_spec_from_collection(remote_specs, requirement, allow_prerelease)
146
150
  return remote_result if local_result.nil?
147
151
 
148
- [local_result, remote_result].max
152
+ [local_result, remote_result].compact.max
149
153
  end
150
154
 
151
- def find_latest_matching_spec_from_collection(specs, requirement)
155
+ def find_latest_matching_spec_from_collection(specs, requirement, allow_prerelease)
156
+ specs = specs.reject {|spec| spec.version.prerelease? } unless allow_prerelease
157
+
152
158
  specs.sort.reverse_each.find {|spec| requirement.satisfied_by?(spec.version) }
153
159
  end
154
160
 
@@ -507,7 +507,15 @@ module Bundler
507
507
 
508
508
  return ["git", *opts, *cmd] unless dir
509
509
 
510
- ["git", "-C", dir.to_s, *opts, *cmd]
510
+ # With safe.bareRepository=explicit, git refuses to discover a bare
511
+ # repository from -C, so the cache clone is named with --git-dir.
512
+ # Working trees, like a local override, still go through -C.
513
+ location = bare_repo?(dir) ? "--git-dir" : "-C"
514
+ ["git", location, dir.to_s, *opts, *cmd]
515
+ end
516
+
517
+ def bare_repo?(dir)
518
+ File.exist?(File.join(dir, "objects")) && File.exist?(File.join(dir, "HEAD"))
511
519
  end
512
520
 
513
521
  def extra_clone_args
@@ -423,10 +423,12 @@ module Bundler
423
423
  def validate_spec(_spec); end
424
424
 
425
425
  def load_gemspec(file)
426
- dirname = Pathname.new(file).dirname
427
- SharedHelpers.chdir(dirname.to_s) do
428
- stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
429
- stub.full_gem_path = dirname.expand_path(root).to_s
426
+ # Expand the path before the chdir below, since resolving it inside the
427
+ # block would base it on the gemspec directory instead of `root`.
428
+ gemspec_path = Pathname.new(file).expand_path(root)
429
+ SharedHelpers.chdir(gemspec_path.dirname.to_s) do
430
+ stub = Gem::StubSpecification.gemspec_stub(gemspec_path.to_s, install_path.parent, install_path.parent)
431
+ stub.full_gem_path = gemspec_path.dirname.to_s
430
432
  StubSpecification.from_stub(stub)
431
433
  end
432
434
  end
@@ -12,7 +12,7 @@ publish = false
12
12
  crate-type = ["cdylib"]
13
13
 
14
14
  [dependencies]
15
- magnus = { version = "0.8.2" }
15
+ magnus = { version = "0.9" }
16
16
  rb-sys = { version = "0.9", features = ["stable-api-compiled-fallback"] }
17
17
 
18
18
  [build-dependencies]
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "4.0.20".freeze
4
+ VERSION = "4.0.22".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= gem_version.segments.first
@@ -119,9 +119,7 @@ module Bundler
119
119
  def bin_path
120
120
  @bin_path ||= begin
121
121
  path = Bundler.settings[:bin] || "bin"
122
- path = Pathname.new(path).expand_path(root).expand_path
123
- mkdir_p(path)
124
- path
122
+ Pathname.new(path).expand_path(root).expand_path
125
123
  end
126
124
  end
127
125
 
@@ -3,17 +3,20 @@
3
3
  require_relative "../command"
4
4
  require_relative "../dependency_installer"
5
5
  require_relative "../gem_runner"
6
+ require_relative "../local_remote_options"
6
7
  require_relative "../package"
7
8
  require_relative "../version_option"
8
9
 
9
10
  class Gem::Commands::ExecCommand < Gem::Command
10
11
  include Gem::VersionOption
12
+ include Gem::LocalRemoteOptions
11
13
 
12
14
  def initialize
13
15
  super "exec", "Run a command from a gem", {
14
16
  version: Gem::Requirement.default,
15
17
  }
16
18
 
19
+ add_source_option
17
20
  add_version_option
18
21
  add_prerelease_option "to be installed"
19
22
 
@@ -204,7 +204,8 @@ class Gem::Ext::Builder
204
204
  when /Cargo.toml/ then
205
205
  Gem::Ext::CargoBuilder.new
206
206
  else
207
- build_error("No builder for extension '#{extension}'")
207
+ # Also called to validate a specification, which must not leave a build log.
208
+ raise Gem::Ext::BuildError, "No builder for extension '#{extension}'"
208
209
  end
209
210
  end
210
211
 
@@ -229,7 +230,11 @@ EOF
229
230
  def build_extension(extension, dest_path) # :nodoc:
230
231
  results = []
231
232
 
232
- builder = builder_for(extension)
233
+ begin
234
+ builder = builder_for(extension)
235
+ rescue Gem::Ext::BuildError => e
236
+ build_error(e.message)
237
+ end
233
238
 
234
239
  extension_dir =
235
240
  File.expand_path File.join(@gem_dir, File.dirname(extension))
@@ -50,6 +50,13 @@ module Gem::GemcutterUtilities
50
50
  socket = server.accept
51
51
  request_line = socket.gets
52
52
 
53
+ # Browsers open connections speculatively and close them again without
54
+ # ever sending a request, so wait for the one that carries the code.
55
+ unless request_line
56
+ socket.close
57
+ next
58
+ end
59
+
53
60
  method, req_uri, _protocol = request_line.split(" ")
54
61
  req_uri = Gem::URI.parse(req_uri)
55
62
 
@@ -75,6 +82,8 @@ module Gem::GemcutterUtilities
75
82
  responder.send(MethodNotAllowedResponse.for(host))
76
83
  raise Gem::WebauthnVerificationError, "Invalid HTTP method #{method.upcase} received."
77
84
  end
85
+ rescue Errno::ECONNABORTED, Errno::ECONNRESET
86
+ socket&.close
78
87
  end
79
88
  end
80
89
 
@@ -684,6 +684,10 @@ class Gem::Installer
684
684
  raise Gem::InstallError, "#{spec} has an invalid name"
685
685
  end
686
686
 
687
+ unless /\A#{Gem::Version::VERSION_PATTERN}\z/.match?(spec.version.to_s)
688
+ raise Gem::InstallError, "#{spec} has an invalid version"
689
+ end
690
+
687
691
  if spec.raw_require_paths.any? {|path| path =~ /\R/ }
688
692
  raise Gem::InstallError, "#{spec} has an invalid require_paths"
689
693
  end
@@ -429,7 +429,7 @@ EOM
429
429
 
430
430
  if entry.symlink?
431
431
  link_target = entry.header.linkname
432
- real_destination = link_target.start_with?("/") ? link_target : File.expand_path(link_target, File.dirname(destination))
432
+ real_destination = File.expand_path(link_target, File.dirname(destination))
433
433
 
434
434
  raise Gem::Package::SymlinkError.new(full_name, real_destination, destination_dir) unless
435
435
  normalize_path(real_destination).start_with? normalize_path(destination_dir + "/")
@@ -272,6 +272,7 @@ class Gem::Uninstaller
272
272
 
273
273
  safe_delete { rm_r full_gem_path, exclusions: exclusions }
274
274
  safe_delete { FileUtils.rm_r spec.extension_dir }
275
+ safe_delete { FileUtils.rm_f spec.build_info_file }
275
276
 
276
277
  old_platform_name = spec.original_name
277
278