I'm looking to push out a registry override for all users on a Linux system (actually, on many hundreds of Linux systems, but that's irrelevant). As far as I can tell, the only way to set system-wide Cargo configuration is by making a file at /.cargo/config
, which is obviously not very friendly to the FHS and is totally different from how all other applications on a Unix-y system are configured.
Does anyone know why this is? It would obviously be a trivial patch to make cargo search /etc/cargo/config
in addition to walking backwards up the tree, and I couldn't find anything in git history to indicate why this isn't done.
A (bad and undocumented) patch to implement this seems to be as simple as:
diff --git a/src/cargo/util/config/mod.rs b/src/cargo/util/config/mod.rs
index b9921dfee..57862ffdc 100644
--- a/src/cargo/util/config/mod.rs
+++ b/src/cargo/util/config/mod.rs
@@ -1302,6 +1302,15 @@ impl Config {
}
}
+ if cfg!(unix) {
+ // Also check system-wide config
+ if let Some(path) = self.get_file_path(Path::new("/etc/cargo"), "config", true)? {
+ if !stash.contains(&path) {
+ walk(&path)?;
+ }
+ }
+ }
+
Ok(())
}
Am I missing something here? Is this just part of the history of cargo/rustup as being user-managed tools and not really considering the managed/enterprise use-case?