Repository navigation
Fix vendored gem refusals naming no remedy (#2091) - #2127
Mikola Lysenko (mikolalysenko) merged 8 commits into
Conversation
Refs #2091. Empty commit that opens the draft pull request; the tests and the fix follow. Assisted-by: Claude Code:claude-fable-5-2
Refs #2091. The group-block, native-extension and platform-build refusals must each name a mode that can patch the gem, and never one that refuses it too. These fail until the next commit. Assisted-by: Claude Code:claude-fable-5-2
Vendored mode refuses a gem declared inside a block, a gem with native extensions and a precompiled platform build. Each error gave the cause and no next step, so a stock Rails Gemfile failed 5 of 7 gems with nothing to act on. Each refusal now names a mode that can patch the gem: hosted mode for a block (with the top-level `group:` form when the block is a plain `group … do`), hosted or agent mode for native extensions, and agent mode alone for a platform build, which hosted mode refuses too. Fixes #2091 Assisted-by: Claude Code:claude-fable-5-2
Review of the first cut found remedies that could mislead: - A gem inside a source, git, github or path block was sent to hosted mode, which refuses it too. The enclosing blocks are now read with formats::gem::ruby::block_stack and agent mode is named there. - The suggested top-level line dropped the declaration's version and options. The remedy now names only the group: option to add. - A gem that is hosted already (the takeover and eject preflight) was told to use hosted mode. It is now told it can stay there. - `socket-patch scan --mode hosted` was quoted as the fix for one gem, though a whole-project hosted scan moves the vendored patches of other ecosystems. The remedies name the mode for the gem, as hosted mode's own refusals do, and the docs say how to patch one gem. Refs #2091 Assisted-by: Claude Code:claude-fable-5-2
clippy::needless_borrow on the four remedy calls. Refs #2091 Assisted-by: Claude Code:claude-fable-5-2
The vendor eject of a hosted gem reaches the indented-declaration refusal through the backend, not the takeover preflight, so the preflight-only "keep it in hosted mode" wording missed it (the e2e eject tests failed). One wording now serves every caller: "leave <gem> to hosted mode (`--mode hosted`)", true whether or not the gem is hosted already. Refs #2091 Assisted-by: Claude Code:claude-fable-5-2
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview
Unit tests, an e2e assertion on JSON refusal output, and a new “Ruby gems: gems vendored mode refuses” section in Reviewed by Cursor Bugbot for commit 6ebb034. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6ebb034. Configure here.
Bugbot: the native-extension refusal is raised before the Gemfile plan, so a native gem inside a source, git, github or path block, or with one of the source options, was still sent to hosted mode, which refuses it (redirect_gem_source_option). The remedy now names agent mode alone for such a declaration. Refs #2091 Assisted-by: Claude Code:claude-fable-5-2
declaration_selects_source kept its own list of source keys, which left out `gitlab:` and custom `git_source` keys that hosted mode refuses (redirect_gem_source_option). For such a gem with a native extension the remedy named `--mode hosted`, a mode that refuses it as well. Use gemfile::source_option, the reader hosted mode refuses with. 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_011f9aeNxATwEfTmV9fd2wYR
|
[agent] PR shepherd: review brief for What it does: When vendored mode refuses a Ruby gem (declared inside a block, builds a native extension, or is a precompiled platform build), the error now also names a way out: move the line to the top level (and spell the Risk: low. It changes message text only. The new helpers just read the Gemfile text, and the block tracker they use is the same one hosted mode already uses. Nothing new is written to disk. Look here:
Verified: I read the whole diff, the issue (#2091) and the one Bugbot thread, which was real, fixed in 2dc2483 and is resolved. The new assertions check the remedy text, so they fail without the change. The served-stub path passes Changes I made: none. Open questions: none blocking. One minor gap: Generated by Claude Code |

LLM Description written by Claude Code:claude-fable-5-2
Fixes #2091
Summary
On a stock Rails Gemfile,
scan --mode vendoredrefuses 5 of 7 patchedgems and each error gives only the cause. This PR adds the way out to
the three refusals involved. No behavior changes: the same gems are
refused with the same codes and exit status; only the
errordetailtext grows, and
docs/ecosystems.mdgains a short section.group :test doblockgroup: :test, or leave rack to hosted mode (--mode hosted)platforms,if, nested blocks)--mode hosted)source/git/github/pathblock--mode agent(hosted mode refuses it too:redirect_gem_source_option)native_extensions_unsupported(local and served stub)--mode hostedor--mode agent, which build the extension (--mode agentalone when the declaration picks the gem's source)platform_gem_unsupported(both branches)--mode agent, which patches a precompiled gem where it is installedThe wording follows hosted mode's own refusals ("patch GEM with
--mode vendoredor--mode agent").Root cause
crates/socket-patch-core/src/vendor/gem.rsbuilt each refusal from thecause alone. The remedies existed (the issue verified them) but were in
no message and in no vendored-mode doc.
How it works
indented_declaration_remedyreads the blocks open at the declarationwith the existing
formats::gem::ruby::block_stack(the tracker thehosted rewriter uses), so it never offers hosted mode inside a
source-selecting block and spells
group:only when exactly one plaingroup … dois open (group_option).vendoreject of a hosted gem raise the samerefusal, so hosted mode is worded as the mode to leave the gem to,
which reads true whether or not the gem is hosted already.
Evidence
4926aecadds the assertions; 7 tests invendor::gemfailed on it, and pass fromede5101on.cargo test -p socket-patch-core: pass.cargo test -p socket-patch-cli --test e2e_redirect_gem_build --test e2e_vendor_gem_build --test e2e_gem_native_ext_build -- --include-ignored(Ruby 3.3.6, Bundler 4.0.18): pass.
cargo clippy --locked --workspace --all-features -- -D warnings(CI's command): clean. With
--all-targetsthe test targets of bothcrates already fail on
mainlints; none is in a line this PR adds.Tests that cover
Fixes #2091:indented_declaration_remedy_fits_the_enclosing_block(every blockshape, CRLF, tabs, the source-block and hosted variants)
test_refuses_unparseable_declaration,takeover_preflight_refuses_a_hosted_gem_inside_a_group_blocktest_refuses_native_extensions,service_native_ext_stub_hard_failstest_refuses_platform_suffixed_dir,test_refuses_unexpected_install_dir_name,test_refuses_native_platform_qualifiervendor_eject_keeps_the_hosted_group_pinine2e_redirect_gem_build.rsasserts the text invendor --json.Review (
/code-review high)Fixed: hosted mode offered inside a source block; a suggested full
gemline that dropped the declaration's version and options; hostedmode offered as news to a gem that is hosted already; a quoted whole-project
socket-patch scan --mode hosted(it moves other ecosystems' vendoredpatches to hosted mode); hand-rolled indentation tracking.
Not fixed, on purpose:
build, a precompiled gem with no source archive and no network). The
remedy names the one mode that can patch such a gem; agent mode's own
error covers those cases.
gemfile_declaration_not_editable(parenthesizedcall, duplicate declaration, …) keep their text. The issue is about
the three refusals above.
Bugbot
One finding, fixed in 2dc2483: the native-extension remedy named hosted
mode for a gem whose declaration picks its source, which hosted mode
refuses. Tests:
test_native_extension_remedy_skips_hosted_for_a_source_selecting_declaration,declaration_selects_source_reads_blocks_and_options.PR shepherd
5de08b6:
declaration_selects_sourcenow reads options with the sharedgemfile::source_option(the reader hosted mode refuses with) instead of itsown key list, which missed
gitlab:and customgit_sourcekeys. Test casesadded to
declaration_selects_source_reads_blocks_and_options.Follow-ups
the refused gems. Not done here: it changes the scan summary for
every ecosystem and wants its own decision.
CLI_CONTRACT.mdis untouched: it does not specify these detailstrings.
https://claude.ai/code/session_011f9aePmQ6T5gENFUUhxnxg
Generated by Claude Code