Repository navigation
Fix the hosted gem warning for a Gemfile with several top-level sources (#2162) - #2164
Conversation
Refs #2162 Assisted-by: Claude Code:claude-fable-5-2
A Gemfile with two top-level `source` lines makes Bundler 2.2 to 2.7 write one GEM section with two remotes. The hosted scan blames a Bundler < 2.2 lock for it and prescribes a `bundle lock` that changes nothing. The new test fails until the warning names the real cause. Refs #2162 Assisted-by: Claude Code:claude-fable-5-2
A Gemfile with more than one top-level `source` line makes Bundler 2.2 to 2.7 lock every gem in one GEM section that names every source. The hosted scan refused such a gem with a warning that blamed a Bundler < 2.2 lock and prescribed `bundle lock`, which writes the same lock again, so the user went round in a loop. The refusal stays (nothing is written), but for that Gemfile the warning now names the top-level sources as the cause and the remedy that works: move each extra source into a `source "<url>" do ... end` block, then `bundle lock`. It offers agent mode only, since vendored mode refuses a gem in a group block or with a native extension, and it does not print the source URLs, which can carry credentials. A stale multi-remote lock under a one-source Gemfile keeps the `bundle lock` remedy, which does rewrite it. A real-Bundler case in e2e_redirect_gem_build covers the refusal and the remedy on Bundler 2.2 to 2.7. Fixes #2162 Assisted-by: Claude Code:claude-fable-5-2
Review follow-ups for the warning on a Gemfile with several top-level sources: - Count every block-less `source` call outside any other construct, a computed URL included, so a second source read from ENV gets the remedy too. A `source` in a conditional or with a trailing modifier is not counted: Bundler may never run it. - Take the new wording only when the multi-remote section is why the lock was refused; any other reason is still reported as it is. - Say hosted mode does not rewrite that lock, not that it cannot be done, and tell the user to keep the patched gem's source top-level. - Bundler 2.2.15 and 2.2.18 keep the one section on `bundle lock` after the Gemfile is fixed (2.2.25 and later split it), so a lock written by an early 2.2 release names a Bundler that splits it. Refs #2162 Assisted-by: Claude Code:claude-fable-5-2
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview The planner now counts top-level sources via Docs ( Reviewed by Cursor Bugbot for commit 425bcbd. Configure here. |
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2162
Summary
A Gemfile with more than one top-level
sourceline makes Bundler 2.2 to 2.7 lock every gem in oneGEMsection that names every source.scan --mode hostedrefuses such a gem (it writes nothing), but the warning blamed a "bundler < 2.2" lock and prescribedbundle lock, which writes the same lock again. The user went round in a loop.The refusal is unchanged. For that Gemfile the warning now:
sourcelines";source, move each other one into asource "<url>" do … endblock, thenbundle lockand re-run;--mode agentonly. Vendored mode refuses a gem in agroupblock or with a native extension, and the hosted planner cannot tell either, so it is no longer offered here;A stale multi-remote lock under a Gemfile with one top-level source keeps the old text: there
bundle lockdoes rewrite the lock (checked on Bundler 2.5.22).Root cause
converge_gem_lock_sourcereported anyGEMsection with several remotes as the layout of Bundler < 2.2, and its caller inplan_gem_redirectappended one fixed remedy without looking at the Gemfile.Changes
formats/gem/hosted.rs:converge_gem_lock_sourcereturns a typedLockRefusalthat says when the multi-remote section is the reason.bundler_keeps_merged_sectionnames the early 2.2 releases (below).formats/gem/declarations.rs:top_level_source_countcounts block-lesssourcecalls outside every other construct. A computed URL counts; asourceinside a conditional or with a trailingifdoes not, since Bundler may never run it.patch/redirect/mod.rs: the new wording, taken only when the refusal is the multi-remote one and the Gemfile has more than one top-level source.docs/ecosystems.mdandCLI_CONTRACT.md: the case is listed underredirect_gem_lock_unconvergeable.No wrapper under
npm/,pypi/orgem/holds this text.Evidence
Real Bundler, run in this session:
bundle lockafter moving the second into a blockGEMsection, two remotesbundle lockleaves it byte for byteBecause of the first row, a lock written by a 2.2 release before 2.2.25 gets "then run
bundle lockwith bundler 2.2.25 or later". I did not run 2.2.19 to 2.2.24; they are taken to keep the section.Tests (each fails on
main, the first two shown red in the first commit):gem_lock_of_a_gemfile_with_several_top_level_sources_names_the_block_remedy: locks as Bundler 2.5.22 and 2.6.9 write them, LF and CRLF, a gem in agroupblock, a computed second source, a URL with credentials.gem_stale_multi_remote_lock_keeps_the_bundle_lock_remedy: one top-level source, a second source in a block, as asource:option, or in anif/else.gem_lock_refused_for_another_reason_is_not_blamed_on_the_sources,gem_lock_of_an_early_bundler_2_2_names_a_bundler_that_splits_it,top_level_source_count_is_the_blockless_calls_outside_any_construct,bundler_keeps_merged_section_names_the_early_2_2_releases.gem_hosted_two_top_level_sources_are_refused_with_the_block_remedyine2e_redirect_gem_build: the refusal,bundle lockleaving the lock alone, then the remedy, a scan that wires the gem, and a frozen install. Passes on Bundler 2.5.22 and 2.2.33 here; fails without the fix. It skips on Bundler 4 (which refuses such a Gemfile) and below 2.2, so on this PR's Bundler 4 leg it prints SKIP and the nightly 2.2 to 2.7 legs run it.Commands run locally:
cargo test -p socket-patch-core --lib(8053 passed),cargo clippy --locked --workspace --all-features -- -D warnings(clean).cargo clippy --all-targetsfails onmaintoo (49 errors in test code of other modules); none are in lines this PR touches.Review findings not fixed
source:option under two top-level sources and write a lock with that gem in a section of its own beside the two-remote section. Hosted mode could wire that directly. The issue calls it a feature outside the report, so the warning only says hosted mode "does not rewrite" such a lock. Worth a follow-up issue.eval_gemfile) or inside a conditional still gets the old text.https://claude.ai/code/session_011f9aeQRcWGFNS21yTAxHto
Generated by Claude Code