Repository navigation
Fix gem unwind warning naming a re-run that cannot work (#2086) - #2156
Mikola Lysenko (mikolalysenko) merged 5 commits into
Conversation
Refs #2086 Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeSmGF7hUwWjuXgRvcM
A hosted rollback or remove that leaves a patched copy in a shared gem home tells the user to re-run with --gem-refresh-shared. The first run removed the wiring, so the re-run exits 1. These tests fail until the unwind names a remedy that works. Refs #2086 Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeSmGF7hUwWjuXgRvcM
After a hosted gem rollback or remove, the warning about a patched copy left in a shared gem home said to re-run with --gem-refresh-shared. The first run removed the wiring, so the re-run exits 1 and the shared copy stays patched. In the unwind direction the warning now names the project-local bundle path, or the files to remove before bundle install fetches the upstream gem into the shared home. Rollback's reinstall note no longer implies that the next install replaces such a copy. Fixes #2086 Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeSmGF7hUwWjuXgRvcM
Review of the unwind remedy: - The cost named for replacing a shared copy by hand was wrong. A project that still pins the hosted patch keeps the upstream copy on its next bundle install; say that instead. - A path in the rm -f remedy is shell-quoted when the shell would split it (a gem home under a directory with a space). - An unwind no longer names --gem-refresh-shared for a project path outside the project directory either. - The end-to-end test asserts rollback's reinstall_required detail and the reason a second unwind fails. Refs #2086 Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeSmGF7hUwWjuXgRvcM
|
[agent] bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview Gem refresh messaging now branches on Rollback’s generic CLI contract, ecosystems docs, unit tests, and a new e2e for Reviewed by Cursor Bugbot for commit 7297439. Configure here. |
The unwind warning now prints each `rm -f` path through `shell_word`, which single-quotes any path holding a character outside the safe set. A Windows path (backslashes) or a temp dir with a space is printed quoted, but three tests still expected the bare `display()` form: `an_unwind_names_no_rerun_for_a_shared_home`, `vendored_unwind_warns_once_in_a_human_run` and `hosted_unwind_names_no_rerun_for_a_shared_gem_home`. Build the expected words with the same quoting (a test-side copy of `shell_word` in the e2e file) so they hold on Windows and with TMPDIR containing a space. Verified on Linux with both the default TMPDIR and one with a space. Assisted-by: Claude Code:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeQRihEsBSmrqzYJhYi
|
[agent] PR shepherd: review brief for the approver What it does Risk: low. Only message text, a new shell-quoting helper (POSIX single quotes with Look here
Verified
Changes I made Open questions (neither blocks merging)
Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed at 0598323. Text only, branching on Direction; the scan-direction text is unchanged and may_replace changes only its reason string. The unwind warning now names a command that can work, and shell_word quoting is correct. Non-blocking: this prints a delete command for a shared gem home, which the earlier contract said never gets a delete list (flagged by the author); rollback --dry-run still does not preview the shared copy left behind.
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2086
Summary
After a hosted gem
rollbackorremove, a patched copy left in ashared gem home (no
BUNDLE_PATH, a Docker image'sGEM_HOME) gets awarning. That warning said to "re-run with
--gem-refresh-shared", butthe re-run exits 1 with "nothing to roll back": the first run already
removed the patch. The user was left on an upstream lock with the patched
gem still installed, and on Bundler 4 a later
bundle pristinefails.Only warning text, the reinstall note and docs change. No run touches a
file it did not touch before.
Before:
After:
Root cause
crates/socket-patch-cli/src/commands/gem_refresh.rsbuilds theshared-home warning from one template for both directions. For a scan a
re-run with the flag works. For an unwind it can't: hosted mode keeps no
ledger, so once the lock is back on its upstream entry nothing records
which gems were patched. The file already knew this for the other unwind
flavors (
retry_hint: "An unwind can't be [retried]"), but theshared-home text was missed.
Making the re-run work is not possible without that state, so the fix
names remedies that work after the unwind.
What changed
upstream_gem_stale_install,human and
--json): no re-run. It names the project-local bundle path,or the files to remove before
bundle install, with what that costsanother project. The scan direction's text is unchanged.
vendor/bundlesymlink):its reason no longer names
--gem-refresh-sharedeither.rm -fremedies shell-quote a path the shell would split (a gemhome under
/Users/Jane Doe). Paths that need no quoting print asbefore.
reinstall_requireddetail nolonger claim the next install replaces such a gem. Next to an
upstream_gem_stale_installwarning they add "(Bundler:bundle installkeeps an installed gem; see the gem warning for what to run)",as they already do for Bun and PyPI.
CLI_CONTRACT.mdanddocs/ecosystems.mddescribe the above. Thedocs now say to pass
--gem-refresh-sharedon therollback/removerun itself.The wrappers under
npm/,pypi/andgem/don't mention the flagand need no change.
Evidence
e2e_redirect_gem_stale_install::hosted_unwind_names_no_rerun_for_a_shared_gem_homerollbackandremove, human and--json: the shared home is left alone, the warning names no re-run and names therm -fcommand, rollback's note defers to it, and a second unwind with the flag exits 1gem_refresh::tests::an_unwind_names_no_rerun_for_a_shared_home--jsondetail and human bulletsgem_refresh::tests::the_rm_remedy_quotes_a_path_the_shell_would_splitgem_refresh::tests::the_policy_decides_what_is_tried(extended)rollback::tests::reinstall_note_defers_to_the_gem_warningThe first two were committed before the fix and failed on the old text
(commit 911a108); they pass from 6e00270 on.
The remedy itself, on real Bundler 4.0.18 / Ruby 3.3.6 with a shared
GEM_HOME:rack 2.2.8installed, its files andcache/archivemodified to stand in for a patched build.
bundle installkept themodified copy. After
rm -f <spec> <archive> && bundle installthe apploaded the upstream code and
bundle pristineexited 0.Local runs:
cargo test -p socket-patch-cli --lib: 958 passed--test e2e_redirect_gem_stale_install: 53 passed--test rollback --test cli_global_args --test e2e_vex_redirect: 138, 13 and 35 passed--test e2e_redirect_gem_build --test e2e_vendor_gem_build -- --ignored(real Bundler): 48 and 11 passedcargo clippy --locked -p socket-patch-cli --all-features -- -D warnings(CI's form): clean.With
--all-targetsclippy fails onmaintoo, in files this PRdoes not touch (
tests/common/mod.rs,src/commands/vendored_backend/repair.rstest code); none of theerrors is in a changed file.
Review (
/code-review high)Seven findings. Fixed in 7297439: the cost sentence (it said another
project "needs a
bundle installtoo", which would not restore apatched build there), unquoted
rm -fpaths, the out-of-tree reason,two weak assertions in the new end-to-end test, and a contract sentence
that overstated the delete-list rule.
Not fixed here:
rollback --dry-rundoes not preview a shared copy the wet run willleave, so no run names
--gem-refresh-sharedbefore the one runwhere it works. The dry run reports no stale gems at all today (it
predates this PR), and adding that is a behavior change of its own. The
docs now say when to pass the flag. A follow-up issue is worth opening.
For the reviewer to decide
The contract said a shared gem home never gets a delete list. In the
unwind direction this PR gives it one, because nothing else can replace
the shared copy once the patch is removed, and a Docker image with one
project in
GEM_HOMEhas no use for the project-local path. If you'drather keep that rule, the alternative is to name the project-local path
alone.
https://claude.ai/code/session_011f9aeSmGF7hUwWjuXgRvcM
Generated by Claude Code