Repository navigation
Fix the stale-gem remedy beside another Ruby tree (#2242) - #2258
Mikola Lysenko (mikolalysenko) wants to merge 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_011f9aeSZGRcxA2epZBuB4RJ
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
A default gem's gemspec stays under specifications/default/, so a bundle install would not put its gem dir back: the remedy for a copy beside another Ruby's tree leaves it. The docs and the contract now say the rule covers any refresh that was turned off or failed. 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
|
[agent] bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview Adds Reviewed by Cursor Bugbot for commit 69e43ed. Configure here. |
|
[agent] PR shepherd: review brief What it does Risk Look here
Verified
Changes I made Open questions Generated by Claude Code |
LLM Description written by Claude Code:claude-fable-5-2
Refs #2242
Summary
After a Ruby upgrade,
vendor/bundleoften holds two trees (ruby/3.2.0besideruby/3.3.0). For a stale gem in the old tree, the hosted scan's remedyrm -f <gemspec> <archive> && bundle installdoes not work: Bundler installs into the tree of the Ruby that runs it, so the unpatched gem directory stays behind with no gemspec. #2251 fixed this where the native rebuild's Ruby probe showed the copy belongs to another Ruby. This PR covers the first part #2251 left: a refresh that is turned off or fails without that evidence (--no-gem-install-refresh,--no-gem-native-rebuild, a patched gem that could not be downloaded,--offline).Where the stale copy's gem home is named by a Ruby ABI version and has another such gem home beside it, the remedy now removes the gem directory too:
That command is right whichever Ruby runs
bundle install: the owner reinstalls the gem, any other Ruby leaves a tree with no copy. Only the text of the warning changes. The warning code, exit codes and JSON shape are as they were, and the scan itself deletes nothing new.Root cause
outlives_reinstallincommands/gem_refresh.rsdecided that the remedy must name the gem directory only from a failed refresh's reason (the probe's "another Ruby's" line, or a missing gemspec). A refresh that stopped earlier carried no such reason, so the remedy fell back torm -f.What changed
beside_another_gem_home: true when the copy's gem home is<dir>/<abi>(3.2.0,3.4.0+1) and<dir>holds another ABI-named directory withgems/andspecifications/. Two gem homes side by side under other names are not counted.outlives_reinstallgainsOutlives::BesideAnotherRubyforWhy::FailedandWhy::Disabled, after the two existing reasons. The re-run hint stays the one the reason already had.specifications/default/) keeps therm -fremedy: nothing would reinstall its gem directory. A copy patched in place, a shared home left alone and a path outside the project are unchanged.docs/ecosystems.mdandCLI_CONTRACT.mddescribe the rule.Evidence
a_copy_beside_another_rubys_tree_is_removed_with_its_gem_dir(commands/gem_refresh.rs): the three reasons, both directions, the lone tree, a non-gem-home sibling, a non-ABI sibling gem home, a default gem and an in-place copy. Failed before the fix with therm -fbullet.an_unrefreshed_copy_beside_another_rubys_tree_is_removed_with_its_gem_dir(e2e_redirect_gem_stale_install): runs the CLI with--no-gem-install-refreshover two trees, checks the human and--jsonremedy, follows it, and re-scans with no warning. Failed before the fix.cargo test -p socket-patch-cli --lib: 1076 passed.cargo test -p socket-patch-cli --test e2e_redirect_gem_stale_install: 68 passed.--test e2e_redirect_gem_build(Ruby 3.x, Bundler 4.0.18): 43 passed.cargo clippy --locked -p socket-patch-cli --all-features -- -D warnings: clean. With--all-targets, clippy reports errors in test helper modules this PR does not touch (tests/prebuilt_common, duplicatemodloads), the same as onmain; none is in a changed file.Review findings not fixed here
/code-review highfound one defect this PR introduced (the default gem case), now fixed with a test. It also listed gaps that were there before and that I left out to keep the change small:bundle installunder the new Ruby still getsrm -f. The follow-up scan then names the gem directory (Fix the stale-gem remedy for a copy in another Ruby's tree (#2242) #2251's missing-gemspec remedy).vendor/bundle/jruby/...besideruby/...) is not counted.--no-gem-install-refreshand a gemspec that is already gone, the warning still offers a re-run first.Still open on #2242
vexdoes not name the path behind anot_appliedomission. That message is shared by every ecosystem.https://claude.ai/code/session_011f9aeSZGRcxA2epZBuB4RJ
Generated by Claude Code