Repository navigation
Hosted gem stale-install guard still flags an unused system gem-home copy under Bundler deployment or the .bundle default path, so scan --mode hosted --vex fails with no_applicable_patches on fresh checkouts #1109
Description
Activity
- addedbugSomething isn't workingSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agentpm:bundlerBundler (RubyGems)Bundler (RubyGems)
on Oct 8, 2026 mikolalysenko commented
on Oct 8, 2026 CollaboratorAuthorMore actions[agent] Triaged as
priority:p1(Bundler). I confirmed the suspect code onmain(05fd82b). InRubyCrawler::bundler_install_homes(ruby_crawler.rs:656),uses_system_gemsis!default_root_has_stores && !bundler_sets_explicit_path(..), andbundler_sets_explicit_path(:1204) reads onlypath/path.system/disable_shared_gems. Sodeployment,default_install_uses_pathandsimulate_version 5aren't modelled.This isn't a duplicate. #1001/#1002 covered the explicit
pathcase only. It's related to #1098 (standalone gemvexjudging the system-home copy), but the two are different code paths: #1098 is aboutvexnot usingbundler_install_homesat all, and this issue is about that function's own "uses system gems" test. A fix for #1098 that routesvexthroughbundler_install_homesshould land after, or together with, this one, so it doesn't inherit the same falsenot_applied.
Generated by Claude Code
- addedv5-blockerMust resolve before v5: public interface/migration or ordinary patch-install-undo failure.Must resolve before v5: public interface/migration or ordinary patch-install-undo failure.and removed
on Oct 8, 2026 mikolalysenko commented
on Oct 9, 2026 CollaboratorAuthorMore actionsv5 release blocker (P1). The documented scan/install/VEX flow must work on a normal Bundler deployment checkout without being blocked by an unused system gem copy.
This follows the maintainer's release scope: one normally completing CLI instance, prioritizing valid-lockfile patch/install behavior, compatibility, and actionable CLI UX.
mikolalysenko commented
on Oct 9, 2026 CollaboratorAuthorMore actions[agent] Claiming this issue (with #1098; shared root cause: the gem crawler has no single model of whether Bundler uses system gems, so
deployment/.bundle-default projects and standalonevexstill judge unusedgem envhomes). Branch: agent/fix-gem-bundler-system-homes. Claim-ID: 2026-10-09T15:21:58Z-105ae7
Generated by Claude Code
mikolalysenko commented
on Oct 9, 2026 CollaboratorAuthorMore actionsmikolalysenko commented
on Oct 9, 2026 CollaboratorAuthorMore actions[agent] #1290 fixes the
deploymentpart of this issue (local config, envBUNDLE_DEPLOYMENT, global config). It does not fix the two.bundle-default variants. In Bundler 4.0.18,Settings::Path#use_system_gems?reads onlybundler_5_mode?(simulate_version 5) and neverdefault_install_uses_path. In 2.5.22 it reads only thedefault_install_uses_pathsettings flag, andFeatureFlagignoressimulate_version. So whether the system home is used depends on which Bundler runs, and a scan can't read that (BUNDLED WITHrecords who wrote the lock, see #751). Skipping the system home on either flag could attest a copy Bundler actually loads, so #1290 keeps judging it (fail closed) and pins that with regression tests. Closing the rest needs a maintainer decision, for example whether socket-patch may shell out tobundle --versionfrom the project root to learn the running Bundler. Leaving this issue open and labeledagent:needs-human.
Generated by Claude Code
[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).
Summary
#1002 fixed #1001 only for an explicit
pathsetting. Bundler also stops using system gems in three other ways:deployment true(the.bundle/configsetting or envBUNDLE_DEPLOYMENT=true), which installs intovendor/bundle;simulate_version 5on Bundler 4.x, which installs into.bundle/;default_install_uses_path trueon Bundler 2.x, which also installs into.bundle/.RubyCrawler::bundler_install_homesstill treats all three as "Bundler uses system gems". So on a fresh checkout or a cold CI cache, before the project's bundle dir exists, an unpatched same-version copy in the machine'sgem envhome is reported as a stale install. The warning is the shared-home flavor, and its remedy tells the user tobundle config set --local path vendor/bundle, which is whatdeploymentalready does. The flagged purl is then dropped from the same run's--vex. With one patched gem,scan --mode hosted --vexexits 1 withno_applicable_patches.Impact
scan --mode hosted --vexon any machine whose shared gem home holds an old copy of the patched gem.paththat isn't installed yet, soscan --mode hosted --vexfails withno_applicable_patcheson fresh checkouts #1001 described.Proof with real Bundler (Ruby 3.3.6)
The system copy is never used in any of these shapes:
deployment trueproj/vendor/bundle/ruby/3.3.0/gems/colorize-0.8.1BUNDLE_DEPLOYMENT=trueproj/vendor/bundle/ruby/3.3.0/gems/colorize-0.8.1simulate_version 5proj/.bundle/ruby/3.3.0/gems/colorize-0.8.1socket-patch repro (main
05fd82b)I used a throwaway test in
crates/socket-patch-cli/tests/e2e_redirect_gem_stale_install.rs. It reuses that file'smount_api,write_manifest_pair,stage_system_home_copyandhosted_vex_scan_with_gem_on_path, exactly likegem_hosted_explicit_bundle_path_ignores_system_home_copy, and only changes the.bundle/config/ env setting. I ran it twice: once with the harness's fakegem, and once with the realgemandGEM_HOMEpointed at the staged home. Both runs gave the same results:.bundle/configor env; nothing installed in the project yet)--vexattestsBUNDLE_PATH: "vendor/bundle"BUNDLE_DEPLOYMENT: "true"no_applicable_patches)BUNDLE_DEPLOYMENT=trueBUNDLE_SIMULATE_VERSION: "5"BUNDLE_DEFAULT_INSTALL_USES_PATH: "true"Warning emitted for the deployment case:
Expected vs actual
gem envhomes count only when Bundler uses system gems, "since with such apathbundle installfetches non-default gems into it and never reuses a system copy". Bundler'sSettings#pathderives the same kind of non-system path fromdeployment(→vendor/bundle) and fromdefault_install_uses_path/simulate_version 5(→.bundle) whenever no tier setspath/path.system/disable_shared_gems. The guard should skip the system homes in those cases, as it does for an explicitpath.path. Its "system gems" test is!default_root_has_stores && !bundler_sets_explicit_path(..), so it falls back to system homes until the deployment store has been installed.OS × version
05fd82b(the logic is OS- and version-independent)First bad version
This isn't a regression. The guard judged every
gem envhome before #1002 (v4.0.0 included). #1002 (f23fd82) narrowed that for an explicitpathonly.Suspect code
crates/socket-patch-core/src/crawlers/ruby_crawler.rs:655-675(bundler_install_homes:uses_system_gemsignoresdeployment,default_install_uses_pathandsimulate_version).crates/socket-patch-core/src/crawlers/ruby_crawler.rs:1204-1229(bundler_sets_explicit_pathreads onlypath/path.system/disable_shared_gems).discover_bundle_stores_impl(ruby_crawler.rs:~452) already knows about the.bundledefault (Gem crawler ignores Bundler's.bundledefault install path (default_install_uses_pathon 2.x,simulate_version 5on 4.x), so agentapplypatches the system copy andvexattestsnot_affectedwhile Bundler loads the unpatched.bundle/ruby/<abi>copy #967), but only probes it once it has been installed.bundler_install_homesthe single answer for standalonevextoo. With this gap, that fix would inherit the same falsenot_appliedfor deployment projects.Backlog review — 2026-10-08
Priority: P1 → P2. Unused system gem copies trigger a false stale-install warning and VEX refusal for a correctly selected Bundler path.