How to manage system-wide cargo configuration for many users

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/ b/src/cargo/util/config/
index b9921dfee..57862ffdc 100644
--- a/src/cargo/util/config/
+++ b/src/cargo/util/config/
@@ -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)?;
+                }
+            }
+        }

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?

Yes, I think so. For reference, here are some links to some related work, though I don't think any of these proposals add a location in /etc to the default config path:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.