Repository navigation
Fix the stale-gem remedy for a copy in another Ruby's tree (#2242) - #2251
Mikola Lysenko (mikolalysenko) merged 4 commits into
Conversation
Refs #2242. 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_011f9aeQSmD8W1tSmEKfea3n
Two failing tests for #2242: the remedy of a native gem in another Ruby's tree, and of a gem directory whose gemspec is already gone. 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_011f9aeQSmD8W1tSmEKfea3n
The hosted scan told the user to rm -f the gemspec and archive of a stale gem and run bundle install. Bundler installs into the gem home of the Ruby that runs it, so for a native gem in the tree of an earlier Ruby the gem directory stayed behind with no gemspec, vex kept omitting the gem, and a re-scan offered the same rm -f for files that were gone. Where a native rebuild found no Ruby owning the install, or the gem directory has no gemspec left, the remedy now removes the gem directory too and names only what is on disk. The retry it names is one that can work. Refs #2242. 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_011f9aeQSmD8W1tSmEKfea3n
Review findings on the remedy for #2242: - A copy left alone because it resolves outside the project is its own reason, so it keeps the remedy it had. - A Ruby that could not be asked is not a Ruby that owns another tree: only a candidate that builds the extension elsewhere counts. - Only not-found says a default gem's gemspec is gone. - The docs no longer state a condition the code does not have. Refs #2242. 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_011f9aeQSmD8W1tSmEKfea3n
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview Stale-gem warnings and remedies now detect when
Docs ( Reviewed by Cursor Bugbot for commit 5da3cb0. Configure here. |
|
[agent] PR shepherd: review brief for the approver What it does Risk: low. It changes only messages and remedy text. Look here
Verified
Changes I made: none. Open questions: none. The leftover case (the refresh stops before the Ruby probe) is already called out for a follow-up. Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed the Why::OutOfTree split, outlives_reinstall and gemspec_is_gone. Only the printed remedy changes; shared, disabled and out-of-tree copies keep the old one. No findings.
Two failing tests for the part of #2242 left by #2251: a stale copy in a gem home beside another Ruby's, left before any Ruby was asked which tree it installs into, still gets the rm -f remedy. Refs #2242. 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_011f9aeSZGRcxA2epZBuB4RJ
The hosted scan's remedy for a stale installed gem is rm -f of its gemspec and archive, then bundle install. Bundler installs into the gem home of the Ruby that runs it, so a copy in the tree of another Ruby keeps its gem dir, with no gemspec. #2251 removed the gem dir where the native rebuild's Ruby probe showed whose the copy is. A refresh that stops before the probe (--no-gem-install-refresh, --no-gem-native-rebuild, a gem that could not be had) still printed the old remedy. Where such a copy's gem home is named by a Ruby ABI and has another one beside it, the remedy now removes the gem dir too. That is right whichever Ruby runs bundle install. A lone tree keeps rm -f. Refs #2242. 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_011f9aeSZGRcxA2epZBuB4RJ
LLM Description written by Claude Code:claude-fable-5-2
Refs #2242
Summary
After a Ruby upgrade,
vendor/bundlecan hold the tree of the earlier Ruby next to the current one. A hosted scan could not rebuild the native gems in the old tree, and told the user to runrm -f <gemspec> <archive> && bundle install. That command does nothing useful there:bundle installinstalls into the gem home of the Ruby that runs it, so the gem directory stayed in the old tree with no gemspec,vexkept omitting the gem, and every re-scan printed the samerm -ffor files that were already gone.The remedy now removes the gem directory too in the two cases where
bundle installwould not replace the copy:rm -rf <gem dir> <gemspec> <archive> && bundle install, and the retry named is "Re-runsocket-patch scanwith the Ruby that installed the gem first onPATH".rm -rf <gem dir> && bundle install, it names only paths that still exist, and no re-run is offered, since a re-run fails the same way.Both the human warning and the
--jsondetail (redirect_gem_stale_install,upstream_gem_stale_install) follow the same rule, in both directions (scan and unwind). Every other remedy is unchanged. Nothing is deleted by socket-patch itself: this only changes the text of the command it prints.Root cause
crates/socket-patch-cli/src/commands/gem_refresh.rsbuilt one remedy for every failed refresh, on the assumption thatbundle installwrites into the gem home that holds the stale copy.What changed
gem_refresh.rs(CLI):outlives_reinstalldecides whether a failed copy needs its gem directory removed,remedy_pathsbuilds the list, andretry_hintpicks a retry that can work.Why::OutOfTree) instead of sharingWhy::Failed, so "a refresh was tried and failed" is a fact the code can check. Its messages are the same as before.gem_ext.rs(core): the "(another Ruby's)" ending of the owning-Ruby error is a public constant, so the CLI and core cannot drift apart on it.docs/ecosystems.mdandCLI_CONTRACT.mddescribe the new remedy.Evidence
a_copy_no_ruby_owns_is_removed_with_its_gem_dir(unit)a_gem_dir_without_its_gemspec_is_the_thing_to_remove(unit)a_gem_dir_left_without_its_gemspec_is_named_as_the_thing_to_remove(e2e, real binary)ruby/3.2.0beside a patchedruby/3.3.0; after the printedrm -rfa re-scan has nothing to warn aboutCommands run locally:
cargo clippy --locked --workspace --all-features -- -D warnings: clean.cargo test -p socket-patch-cli --lib: 1069 passed.cargo test -p socket-patch-core --lib gem_ext: 75 passed.cargo test -p socket-patch-cli --test e2e_redirect_gem_stale_install --test e2e_gem_native_ext_build --test e2e_vex_redirect: 67, 43 and 35 passed (11 ignored host capstones in the native build suite).cargo clippy --all-targetsreports 68 errors in test files this PR does not touch; they are the same onmainand CI's clippy job does not build those targets.There is no end-to-end test with two real Rubies: no CI leg installs two. The issue's exact case is covered by the unit test, which feeds the report the reason string the issue quotes.
Code review
/code-review highfound five things. Three are fixed in the last commit:Why::OutOfTree.One was a docs sentence that stated a condition the code does not have; reworded.
One is not fixed, and is why this is
Refsand notFixes: a copy in another Ruby's tree still gets the oldrm -fremedy when the refresh stops before the Ruby probe (--no-gem-install-refresh, a download or offline failure,--no-gem-native-rebuild). Fixing that needs the scan to know which Ruby will runbundle installwithout probing one, which is a larger change. Once such a run leaves a directory without a gemspec, the next scan that tries a refresh names the directory.Left for a follow-up
vexto name the path it objects to in its "omitting … (not_applied)" warning. That message is shared by every ecosystem and is not changed here.https://claude.ai/code/session_011f9aeQSmD8W1tSmEKfea3n
Generated by Claude Code