Repository navigation
Fix gem remedy naming a mode that refuses too (#2151) - #2160
Conversation
Assisted-by: Claude Code:claude-fable-5-2
A gem the lock lists as a direct dependency but the Gemfile declares in a gemspec, an eval_gemfile'd file or a loop is refused by hosted and by vendored mode for the same reason. These tests pin that the hosted warning names no mode that refuses the gem as well, that the vendored refusal names its ways out, and (against real Bundler) that both of those work when followed. They fail until the next commit (#2151). 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_011f9aePcxbHH9zFcxrD7z4f
A gem the lock lists as a direct dependency but the Gemfile declares out of sight (a gemspec, an eval_gemfile'd file, a loop) is refused by hosted and by vendored mode for the same reason: either would add a second declaration, and Bundler refuses the Gemfile. The hosted warning still sent the user to --mode vendored, which exits 1 on the same gem, and the vendored refusal named no way out. The hosted warning now names the literal gem line and --mode agent only. The vendored refusal names one literal gem line (above `gemspec` where the Gemfile has that directive, since a line below it is refused next for the merged requirement) or --mode agent. The docs and the CLI contract say the same. Fixes #2151 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_011f9aePcxbHH9zFcxrD7z4f
Review of the previous commit: for a gem declared in an eval_gemfile'd file or a loop, a literal line added next to the hidden gem call would be pinned by the next run (an exact version and path: in vendored mode, source: in hosted mode), and Bundler refuses a Gemfile whose two declarations of a gem differ. Both remedies now say the line stands in place of any other gem call that declares the gem, and the end-to-end test follows that for an eval_gemfile'd declaration. The vendored refusal no longer says "above gemspec" for a Gemfile whose gemspec directives cannot be read, which may have none. The docs no longer say vendored mode can patch every gem a hosted warning names it for. Refs #2151 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_011f9aePcxbHH9zFcxrD7z4f
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview Hosted redirect ( Vendored mode gains shared remedy text via Docs ( Tests cover message content in Reviewed by Cursor Bugbot for commit 0831ba5. Configure here. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0831ba5. Configure here.
|
[agent] PR shepherd: review brief for the approver (head What it does: this fixes #2151. Take a gem that only a gemspec (or an Risk: low. No run writes anything different. Only two error and warning strings change, and Look here:
Verified:
Changes I made: none. Open questions: none blocking. The description's "Not fixed here" section lists two related dead ends in other gem warnings that need their own issue. Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed at 0831ba5. Message and docs text only; matches the Expected section of #2151. The hosted warning no longer names --mode vendored, and the vendored refusal gains a remedy from a read-only parse that drops the hint when the parse fails. Non-blocking: other hosted warnings still name --mode vendored for shapes vendored mode refuses (listed in the PR body as out of scope).
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2151
Summary
In a gem library (
Gemfilewithgemspec), a patched gem that only the gemspec declares is skipped by hosted mode withredirect_gem_declaration_not_visible. The warning told the user to "patch it with--mode vendoredor--mode agent". Vendored mode refuses the same gem for the same reason, exits 1 and named no way out. This PR changes message text and docs only; no run writes anything different.gemline or--mode agent.--mode vendoredis gone.gemfile_declaration_not_editable, "as a direct dependency"): now ends with its way out, one literalgem "<name>"line (abovegemspecwhen the Gemfile has that directive) or--mode agent. It does not name hosted mode.gemcall that declares the gem. See "Review finding" below for why.docs/ecosystems.mdandCLI_CONTRACT.mdsay the same. The docs sentence that promised vendored mode for every gem hosted mode skips now points at vendored mode's own refusals.After the change:
Root cause
Both modes refuse a gem the lock lists under
DEPENDENCIESwhen they can find nogemline for it, because the line they would add is a second declaration. The hosted text was written before vendored mode had that gate, and the earlier pass that gave the vendored refusals a remedy (#2091) missed this one.Why "above
gemspec"With a line below
gemspec, Bundler 2.7+ merges the gemspec's development requirement into it, and vendored mode then refuses the gem for that (its existing refusal, which already says "move the declaration abovegemspec"). Naming the place up front saves the user that second refusal. The hint is only given when the Gemfile'sgemspecdirectives can be read.Review finding fixed in the second commit
/code-review highpointed out that for aneval_gemfiled file or a loop, a user who adds a literal line next to the hiddengemcall gets it pinned by the next run, and Bundler refuses a Gemfile whose two declarations of a gem differ. I confirmed that on Bundler 4.0.18 (gem "rack", "3.2.8"plus aneval_gemfiledgem "rack", "~> 3.1"failsbundle lock; two identical lines do not). The old hosted text had the same gap. Both remedies now say the line replaces the hidden call.Evidence
vendor::gem::tests::direct_dependency_declared_out_of_sight_refuses_instead_of_appendingeval_gemfile, a loop,gemspec(LF and CRLF, withpath:), and a variable namedgemspec(no hint)patch::redirect::tests::gemfile_direct_dependency_declared_out_of_sight_is_not_appendedand the refusal table test next to itgem_vendor_gemspec_only_dependency_refusal_names_remedies_that_work(new)gemline abovegemspecvendors and installs frozen, reverts byte for byte; thenapply(agent mode) patches the installed gem with the Gemfile untouchedgem_vendor_refuses_an_eval_gemfile_direct_dep(extended)The commit "Test the remedies of a gem declared out of sight" holds the tests alone and fails (2 unit tests and the new e2e test); the two commits after it make them pass.
Local runs, Ruby 3.3.6:
cargo test -p socket-patch-core: pass (7947 unit tests).cargo test -p socket-patch-cli --test e2e_vendor_gem_build --test e2e_redirect_gem_build -- --ignoredon Bundler 4.0.18: pass.cargo clippy --locked -p socket-patch-core -p socket-patch-cli --all-features -- -D warnings(the form CI runs): clean. With--all-targetsclippy reports errors in test code onmainas well; none are in lines this PR touches.CI on
0831ba5:ci-okandclippygreen, Bugbot found no issues, no open review thread.Not fixed here
redirect_gem_unrecognized_declaration,redirect_gem_source_option) still name--mode vendoredfor some declarations vendored mode refuses too, for examplegroup(:test) { gem "rack" }or agit:option. That is the same kind of dead end with a different cause per shape, found by the review and not covered by Hosted gem scan sends a gemspec-declared gem to--mode vendored, which refuses it for the same reason and names no remedy #2151. It needs its own issue.gem(call whose name is on a later line, which hosted mode can edit. The message blames aneval_gemfile, a loop or a gemspec there, as it did before.https://claude.ai/code/session_011f9aePcxbHH9zFcxrD7z4f
Generated by Claude Code