`gem update` fails on 4.0.9: minitest binstub not patched for RubyGems overwrite detection

Offen
#80 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
ruby
Bereich
build-system

Rechercherichtung

Start with libexec/package.rb, especially patch_executables, and compare its shebang matching with the minitest executable described in the issue. Review the proposed fork commit and the existing fix for issue #6 to understand the intended RubyGems marker behavior. Done means Ruby shebang variants are patched and a runtime check catches bundled gem executables RubyGems would overwrite during an offline reinstall.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

What were you trying to do when you hit this?

Updating my installed gems with gem update.

What you ran

gem update on Ruby 4.0.9 (ruby-4.0.9.macos.tar.gz), installed via mise 2026.11.14 on macOS 27.2.1 arm64.

What happened
minitest's executable "minitest" conflicts with .../installs/ruby/4.0.9/bin/minitest
Overwrite the executable? [yN]
ERROR:  Error installing minitest:
        "minitest" from minitest conflicts with .../installs/ruby/4.0.9/bin/minitest

minitest stays at the bundled 6.0.0. I expected it to update to 6.1.0. gem update rake on the same install works.

Version

Ruby 4.0.9, macOS arm64

Cause and fix

This is the same RubyGems overwrite detection that #6 fixed for rbs. patch_executables only matches #!/usr/bin/env ruby, but minitest 6, which is bundled from Ruby 4.0, starts its executable with #!/usr/bin/env -S ruby. Its binstub is never patched.

PRs are limited to collaborators, so the fix is on my fork: https://github.com/ArloL/ruby/commit/63e57f301fd83faba926f36d6c797b1bb3e3bba7

  • Match any Ruby shebang (^#!.*ruby.*\n) when adding the RubyGems marker.
  • Add a runtime check that reinstalls every bundled gem with an executable from its cached .gem (offline). A binstub RubyGems won't overwrite now fails the build.

On the 4.0.9 macOS release tarball, the new check fails at minitest on the released binstubs and passes after the fix. With the marker stripped from all stubs (the #6 bug), it fails at bootsnap.

I hit this during a routine gem update. Claude Code helped me trace the cause and write the fix.

Vorherrschende Sprache
Ruby
Sterne
47
Forks
9
Ø Merge
2 Std. 41 Min.
Gemergte PRs (30 T.)
6

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Ähnliche Issues

Weitere Issues zu Ruby

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.