Skip to content

Commit 81f3fac

Browse files
committed
Fix: prevent patching global gem homes when bundle stores exist
When env/config bundle roots have stores, get_gem_paths was appending gem env homes and apply was patching every gem copy including the shared global home. This caused permission failures or unwanted mutation of machine-wide gems even though bundle exec loads the bundle copy. Change the early-return condition to trigger for ANY bundle stores (not just default_root_has_stores), preventing global gem homes from being added as patch targets when bundle stores exist.
1 parent af59554 commit 81f3fac

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

crates/socket-patch-core/src/crawlers/ruby_crawler.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ impl RubyCrawler {
7777
)
7878
.await;
7979

80-
// Historic early-return, kept ONLY for the implicit project-local
81-
// `vendor/bundle` probe: a deployment-style install is the
82-
// project's one gem source, so the ambient gem homes don't apply.
83-
// Stores found via an env/config root do NOT suppress the fallback
84-
// below: default gems (rexml, json, …) never live in a bundle path
85-
// — they ship with ruby in the DEFAULT/system gem homes — so an
86-
// env-`BUNDLE_PATH` project still needs the `gem env` homes to see
87-
// them (the explicit-roots feature briefly suppressed that
88-
// pre-existing fallback).
89-
if discovery.default_root_has_stores {
80+
// When ANY bundle stores are found (vendor/bundle, env, or config),
81+
// return ONLY those stores without appending `gem env` homes. A
82+
// deployment-style install or an env/config-rooted store is the
83+
// project's gem source, so the ambient gem homes must not become
84+
// apply patch targets — patching a machine-wide global gem home
85+
// (which `bundle exec` doesn't load) risks permission failures and
86+
// the nuget-style global-cache hazard this otherwise avoids.
87+
// Default gems (rexml, json, …) never in a bundle path also aren't
88+
// in the manifest, so skipping the fallback here is safe.
89+
if !discovery.stores.is_empty() {
9090
return Ok(discovery.stores);
9191
}
9292

0 commit comments

Comments
 (0)