Skip to content

Commit f329b2f

Browse files
Fix vendored gem refusals naming no remedy (#2091) (#2127)
* Start: vendored gem refusals name a remedy Refs #2091. Empty commit that opens the draft pull request; the tests and the fix follow. Assisted-by: Claude Code:claude-fable-5-2 * Test that vendored gem refusals name a remedy 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 * Name a remedy in vendored gem refusals 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 * Fit each gem refusal's remedy to its cause 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 * Drop needless borrows in gem remedies clippy::needless_borrow on the four remedy calls. Refs #2091 Assisted-by: Claude Code:claude-fable-5-2 * Word the hosted remedy for an eject too 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 * Skip hosted in native remedy for source gems 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 * Read gem source options with the shared reader 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 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 911bf16 commit f329b2f

3 files changed

Lines changed: 338 additions & 9 deletions

File tree

‎crates/socket-patch-cli/tests/e2e_redirect_gem_build.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3673,6 +3673,15 @@ fn vendor_eject_keeps_the_hosted_group_pin(fx: &RedirectFixture, dry_run: bool)
36733673
events[0]["errorCode"], "gemfile_declaration_not_editable",
36743674
"{label}: {env}"
36753675
);
3676+
// #2091: the refusal says how to get out of it. The gem is declared in
3677+
// a `group :development do` block, which one top-level option replaces,
3678+
// and it is hosted already, so hosted mode is the mode to leave it to.
3679+
let detail = events[0]["error"].as_str().unwrap_or_default();
3680+
assert!(
3681+
detail.contains("move it to the top level with the option `group: :development`")
3682+
&& detail.contains(&format!("or leave {DEP} to hosted mode (`--mode hosted`)")),
3683+
"{label}: the refusal names both ways out: {env}"
3684+
);
36763685
assert_eq!(env["error"]["code"], "eject_refused", "{label}: {env}");
36773686
assert!(
36783687
!stdout.contains("eject_planned") && !stdout.contains("eject_rolled_back"),

0 commit comments

Comments
 (0)