GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||
GeezerVison is showing github.com — Fix Gemfile rewrites duplicating gem declarations (#482, #548) by mikolalysenko · Pull Request #552 · SocketDev/socket-patch Conversation
|
| Issue | Regression test(s) | Without fix | With fix |
|---|---|---|---|
| #548 (gem declared twice) | patch::redirect::tests::gemfile_gem_declared_twice_fails_closed; Bundler capstone Driver::ScanVexDuplicateDeclaration in e2e_redirect_gem_build |
FAILED | ok |
| #548 (Bugbot follow-up: another gem call quoting the name is not a duplicate) | patch::redirect::tests::gemfile_name_quoted_by_another_gem_call_still_rewrites |
FAILED | ok |
| #482 (eval_gemfile / loop direct dep) | patch::redirect::tests::gemfile_direct_dependency_declared_out_of_sight_is_not_appended, vendor::gem::tests::direct_dependency_declared_out_of_sight_refuses_instead_of_appending; Bundler capstones in e2e_redirect_gem_build and e2e_vendor_gem_build |
FAILED | ok |
Commands run locally (Ruby 3.3.6, Bundler 4.0.17):
cargo clippy --workspace --all-features -- -D warnings: cleanrustfmt --check on every file this PR touches: hunks clean (main has pre-existing unformatted code elsewhere, and CI does not gate on fmt)cargo test --workspace --all-features --no-fail-fast: 208 test binaries ok. 12 failures, all write-permission-failure tests (*_write_failure_*, *unremovable*, relax_loop_must_not_traverse_symlinked_root) that cannot fail as root in this sandbox. None touch gem code.cargo test -p socket-patch-cli --all-features --test e2e_redirect_gem_build -- --ignored: 10 passedcargo test -p socket-patch-cli --all-features --test e2e_vendor_gem_build -- --ignored: 6 passed (re-run on e13a087: both gem build suites green again)e2e_gem needs the live patch API, which this sandbox cannot reach; left to CI🤖 Generated with Claude Code
https://claude.ai/code/session_01Lkn7GeDBpBAZrZ1sFQuc1y
Note
Medium Risk
Changes hosted redirect and vendored Gemfile planning for gems; behavior is fail-closed with new warnings/errors, but incorrect lock parsing or declaration counting could block legitimate patches.
Overview
Fixes #482 and #548 by making gem hosted redirect and vendored Gemfile edits fail closed instead of leaving Bundler with duplicate or conflicting declarations.
The shared lock parser now tracks every name under DEPENDENCIES (GemfileLock::direct / lock_lists_direct_dependency). Hosted redirect counts real gem declarations whose first argument is the target gem; more than one yields redirect_gem_declared_more_than_once with no Gemfile/lock writes. If the rewriter cannot see a declaration but the lock lists the gem as direct (eval_gemfile, loops, etc.), it skips with redirect_gem_declaration_not_visible instead of appending a source block. Vendored mode refuses an Append plan in that situation as gemfile_declaration_not_editable via refuse_append_of_direct_dependency.
Unit tests cover duplicate declarations, false-positive guards (require: / comments), and out-of-sight direct deps; e2e capstones exercise two-group Gemfiles, eval_gemfile, and vendor refusal on the same layout.
Reviewed by Cursor Bugbot for commit fdbf3af. Configure here.
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Assisted-by: Claude Code:claude-opus-5-5
Hosted and vendored modes could leave a Gemfile that Bundler refuses
on every install ("You cannot specify the same gem twice"):
- Hosted mode rewrote only the first of several declarations of a gem
(for example one in each of two `group` blocks), leaving an exact
pin next to the original requirement (#548). It now refuses with
redirect_gem_declared_more_than_once, as vendored mode already did.
- Both modes treated a gem they could not see declared in the root
Gemfile as transitive and appended a second declaration, even when
the lock lists it under DEPENDENCIES because the Gemfile declares it
through eval_gemfile or a loop (#482). Both now refuse instead.
Fixes #482
Fixes #548
Assisted-by: Claude Code:claude-opus-5-5
A direct dependency declared through eval_gemfile must be refused before any write (#482), and Bundler must still install the project frozen and unfrozen. Assisted-by: Claude Code:claude-opus-5-5
Wraps one long assert in the new Bundler capstone so rustfmt leaves the file unchanged. No behavior change. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Hosted redirect refused a Gemfile with one editable declaration when another gem call quoted the same name, e.g. `gem "other", require: "rack"` or a trailing comment. Only `gem` calls whose first argument is the gem now count toward the more-than-once refusal. The looser probe still gates appending a source block. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
[burn-down agent] Labeled Ready for review at
Slack announcement not sent (no Slack send tool available this run). Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
bugbot run Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
✅ 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 fdbf3af. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Reviewed Validation: 261 gem unit tests passed on the original head. On the merged code, 11 real-Bundler hosted tests and the vendor |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
[burn-down agent] Labeled Ready for review at
Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Hosted gem redirect rewrites only the first of a gem's declarations, so a gem listed in twogroup blocks makes every bundle install fail with "You cannot specify the same gem twice"
Hosted gem redirect appends a second declaration when the gem is declared through eval_gemfile or a loop, so every bundle install fails with "You cannot specify the same gem twice"
There was an error while loading. Please reload this page.