Repository navigation
Description
[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).
Summary
After a hosted scan (or get --mode hosted) wires exactly one gem, the "update hold" note prints the command to undo that gem's pin with the patch record's full purl, unquoted:
To move it to a newer release, run `socket-patch rollback pkg:gem/rack@2.2.8?platform=ruby`, then `bundle update rack`, then `socket-patch scan` again.
? is a glob character. Pasted as printed, the command fails in zsh, the default shell on macOS (zsh: no matches found: pkg:gem/rack@2.2.8?platform=ruby), and in bash with failglob. In bash with nullglob the argument is dropped and the shell runs a bare socket-patch rollback, which unwinds every patch in the project. The note exists to prevent exactly that (CLI_CONTRACT: "never a bare rollback, which would unwind every patch").
Impact
The first remedy a new user is given for the most common follow-up (taking a newer release of a patched gem) does not run on a stock macOS terminal, and the error comes from the shell, so nothing tells them to quote the argument. Gem patch records carry the ?platform=ruby qualifier, so every one-gem run prints it.
Repro
Any project where one gem gets a hosted patch. With the repo's stand-in for the patch service (tests/nokogiri/patch_service.rb, a PatchService.new("rack", "2.2.8", [], …) instance at $URL):
mkdir demo && cd demo
printf 'source "https://rubygems.org"\n\ngem "rack", "2.2.8"\n' > Gemfile
bundle config set --local path vendor/bundle && bundle install
socket-patch scan --mode hosted --yes --api-url $URL --patch-server-url $URL --api-token fake --org nokogiri-e2e | grep 'To move'
# what a shell makes of the printed command
bash -O failglob -c 'echo socket-patch rollback pkg:gem/rack@2.2.8?platform=ruby'
bash -O nullglob -c 'echo socket-patch rollback pkg:gem/rack@2.2.8?platform=ruby'Bundler now takes rack from its Socket patch source only, ... To move it to a newer release, run `socket-patch rollback pkg:gem/rack@2.2.8?platform=ruby`, then `bundle update rack`, then `socket-patch scan` again.
bash: line 1: no match: pkg:gem/rack@2.2.8?platform=ruby
socket-patch rollback
The sandbox has no zsh, so the zsh line above is its documented default (NOMATCH), not a captured run. The two bash lines are captured.
Expected
docs/ecosystems.md ("Ruby gems: hosted mode") and crates/socket-patch-cli/CLI_CONTRACT.md ("Update hold") both show the command as socket-patch rollback pkg:gem/rack@3.1.8, with no qualifier. socket-patch rollback pkg:gem/rack@2.2.8 works (checked: it restores the pair and the installed gem), so the printed command should be that, or the purl should be quoted.
Actual
The note prints the record's purl with its ?platform=ruby qualifier, unquoted. The several-gems form of the note (pkg:gem/<gem>@<version>) is fine.
Versions
| Bundler | Ruby | Gem | Result |
|---|---|---|---|
| 4.0.18 | 3.3.6 | rack 2.2.8 (ruby platform) | prints ?platform=ruby |
| 4.0.18 | 3.3.6 | ffi 1.17.4, sqlite3 2.10.2 (precompiled) | prints ?platform=ruby |
| 2.5.22 | 3.3.6 | nokogiri 1.18.10 (precompiled), monorepo root scan | prints ?platform=ruby |
Tested on main 6579162, Linux. It does not depend on the Bundler version. On Windows, cmd and PowerShell pass ? through, so the command works there.
Suspect
crates/socket-patch-cli/src/commands/scan/hosted.rs:2927 (format_gem_hold_note): target is the confirmed pin's purl as recorded. Its unit test (hosted.rs:5542) only uses unqualified purls. Other printed commands interpolate a record's purl the same way (commands/rollback.rs:355, commands/list.rs:1088, commands/scan/withdrawn.rs:248, commands/scan/gc.rs:399); I did not run those.
Generated by Claude Code
Activity