diff --git a/src/config/mod.rs b/src/config/mod.rs index b0c4b13d20..21613e3a29 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -102,7 +102,27 @@ impl Config { self.packages.insert(package, package_config); } - self.files.extend(other_files); + // File entries from later-included configs override earlier ones for + // the same path. Previously this was `self.files.extend(other_files)`, + // which silently accumulated duplicate paths and left the winner to + // whichever entry the installer wrote last — an invisible, order- + // dependent override that is a frequent source of "my config edit did + // nothing" confusion (e.g. an init service redefined by a legacy + // overlay config). Make the override explicit and visible: warn on the + // console and replace in place so the last definition deterministically + // wins with no duplicate left in the list. + for file in other_files { + if let Some(existing) = self.files.iter_mut().find(|f| f.path == file.path) { + eprintln!( + "config: WARNING: file '{}' redefined by a later-included config \ + (override — last definition wins)", + file.path + ); + *existing = file; + } else { + self.files.push(file); + } + } for (user, user_config) in other_users { self.users.insert(user, user_config);