Repository navigation
Fix vendored transitive gem loading at boot (#2084) - #2097
Mikola Lysenko (mikolalysenko) merged 4 commits into
Conversation
Refs #2084 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_011f9aePqWf8D86MUbLkwZbv
A gem the Gemfile does not declare gets a managed block from vendored mode. The tests pin that its declaration carries `require: false`, that a block an older release wrote gains it on a re-vendor and can still be reverted, and that an edited block line is left alone. These fail until the next commit. Refs #2084 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_011f9aePqWf8D86MUbLkwZbv
Vendored mode declares a gem the Gemfile does not name in a managed block at the top level of the Gemfile. The declaration had no `require: false`, so `Bundler.require` loaded the gem at boot, which it did not do before the scan. Hosted mode writes the option on the line it adds for the same reason. The block is now written with `require: false`. A block an older release wrote gains the option when a patch update re-vendors the gem; a block line with anything after its `path:` was edited by hand and is repointed as before. The revert already accepts both forms. The transitive end-to-end test now boots the fresh checkout with `Bundler.require` and fails if the gem is loaded. Fixes #2084 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_011f9aePqWf8D86MUbLkwZbv
A re-vendor gave the managed block's line `require: false` whenever no keyword option or comment followed its `path:`. A hand-edited line with a statement modifier or a `;` after the path passed that test, and the option landed outside the call's arguments: a Ruby syntax error in the Gemfile, or an option on another gem's call. The option is now added only when the line ends at the closing quote of its `path:` value, the form older releases wrote. Any other line is repointed and otherwise left alone. Refs #2084 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_011f9aePqWf8D86MUbLkwZbv
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview Gemfile wiring in Tests: unit coverage for append/revert/revendor edge cases; the transitive e2e capstone runs Reviewed by Cursor Bugbot for commit 3fbeeea. 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 3fbeeea. Configure here.
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2084
Summary
Vendored mode patches a gem the
Gemfiledoesn't declare by appending a managed block that declares it. The declaration had norequire: false, soBundler.require(what a Rails app runs at boot) started loading the gem, which it did not do before the scan. The block is now written as:Hosted mode already writes
require: falseon the line it adds for such a gem.Root cause
plan_gemfile_editincrates/socket-patch-core/src/vendor/gem.rsformatted the appended declaration asgem "<name>", "<version>", path: "<rel>". Bundler auto-requires every declared gem of the default group unless the declaration says otherwise.What changed
, require: false(LF and CRLF Gemfiles).RewireOurspath). Only a block line that ends at the closing quote of itspath:value is changed, which is the exact form older releases wrote. A line with anything after it (an option, a comment,if ...,;) was edited by hand and is repointed as before, byte for byte.CLI_CONTRACT.mddescribes the option in the vendoring table.Evidence
cargo test -p socket-patch-core --libcargo test -p socket-patch-cli --test e2e_vendor_gem_build -- --ignored(Ruby 3.3.6, Bundler 4.0.18)cargo test -p socket-patch-cli --test in_process_vendor --test e2e_vex_vendorcargo clippy --locked --workspace --all-features -- -D warnings(CI's command)Tests for #2084:
appended_block_declares_the_gem_require_false, and the updated byte-exact block assertions in five existing tests. Commit c63b043 holds the tests alone; 7 of them fail there and pass from a65c8b6.gem_vendor_transitive_dep_fresh_checkout_and_revert(end to end, real Bundler) now boots the fresh checkout withBundler.require(:default)and fails iflib/rack.rbis loaded. Without the fix it fails with "Bundler.require loaded the vendored transitive gem".revendor_adds_require_false_to_an_older_block,revert_removes_an_older_block_without_require_false(LF and CRLF),revendor_keeps_an_edited_block_line_as_it_is,revendor_never_adds_require_false_outside_the_block.cargo clippy -p socket-patch-core --all-targetsreports 44 errors in test targets onmaintoo (none in the files of this PR); CI's clippy job does not lint test targets.Review findings not fixed
/code-review highreported four findings. One was a real bug and is fixed in 3fbeeea (the option could land after a statement modifier on a hand-edited block line). The other three are left as they are:vendor --revertfollowed by a new vendor run rewrites it. Healing it on a no-op run means rewriting a committedGemfileand its ledger record on a run that today changes nothing, and warning about it means a new warning code. Both change CLI behavior, so they need a maintainer's decision (see below).require: falsefrom the block on purpose gets it back at the next patch update. That line can't be told apart from one 5.1 wrote. Writingrequire: truekeeps the gem auto-required, since a line with an option afterpath:is never changed., require: falseexists here and in hosted mode'sadded_line. Sharing a two-word constant would add the hosted rewriter to this diff for no change in behavior.For a maintainer
Should a same-uuid
vendor/scan --mode vendoredrun rewrite a 5.1 block to addrequire: false, warn about it, or leave it (current behavior)? I can do either in a follow-up PR.https://claude.ai/code/session_011f9aePqWf8D86MUbLkwZbv
Generated by Claude Code