{"record":{"id":"6c4bf713328df002","repo":"rust-lang/rust","slug":"git-command-failed","errorCode":null,"errorMessage":"git command failed","messagePattern":"git command failed","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/ci/citool/src/utils.rs","lineNumber":53,"sourceCode":"/// Normalizes Windows-style path delimiters to Unix-style paths.\npub fn normalize_path_delimiters(name: &str) -> Cow<'_, str> {\n    if name.contains(\"\\\\\") { name.replace('\\\\', \"/\").into() } else { name.into() }\n}\n\npub fn init_submodule_if_needed<P: AsRef<Path>>(path_to_submodule: P) -> anyhow::Result<()> {\n    let path_to_submodule = path_to_submodule.as_ref();\n\n    if let Ok(mut iter) = path_to_submodule.read_dir()\n        && iter.any(|entry| entry.is_ok())\n    {\n        // Seems like the submodule is already initialized, nothing to be done here.\n        return Ok(());\n    }\n    let mut child = Command::new(\"git\")\n        .args(&[\"submodule\", \"update\", \"--init\"])\n        .arg(path_to_submodule)\n        .spawn()?;\n    if !child.wait()?.success() { Err(anyhow::anyhow!(\"git command failed\")) } else { Ok(()) }\n}\n","sourceCodeStart":35,"sourceCodeEnd":55,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/ci/citool/src/utils.rs#L35-L55","documentation":"Thrown by init_submodule_if_needed when the spawned `git submodule update --init <path>` process exits with a non-zero status. citool calls this for src/llvm-project/ before running a job, to ensure the LLVM submodule is populated when the directory is empty.","triggerScenarios":"The submodule path is empty and git fails to clone it: network/git authentication error, missing network access, submodule URL changed in .gitmodules, or a corrupt local git index.","commonSituations":"Running citool in an environment without network egress to the LLVM git server; a shallow/partial clone whose .git/modules is inconsistent; .gitmodules points at an unreachable mirror; git credentials not configured for a private mirror.","solutions":["Run `git submodule update --init src/llvm-project/` manually to see git's own error output.","Verify network connectivity and access to the LLVM repository URL in .gitmodules.","If the submodule is already initialized, ensure the directory is non-empty so citool skips this step.","Re-run `git submodule deinit -f src/llvm-project` then re-init if the local submodule state is corrupt."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// Skip the submodule init if the directory is already populated (citool already does this).\nif path_to_submodule.read_dir().map(|mut d| d.next().is_some()).unwrap_or(false) {\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = init_submodule_if_needed(\"src/llvm-project/\") {\n    eprintln!(\"git submodule init failed: {e:#}\");\n    eprintln!(\"Run `git submodule update --init src/llvm-project/` manually to diagnose.\");\n    return Err(e);\n}","preventionTips":["Pre-populate large submodules (llvm-project) before running citool in restricted-network environments.","Ensure network egress to the submodule git server is available where citool runs.","Keep .git/modules consistent; re-run submodule deinit/init on corruption."],"tags":["ci","citool","git","submodule","network"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}