{"record":{"id":"0885f1cde66ecf47","repo":"nikivdev/code","slug":"failed-with-status","errorCode":null,"errorMessage":"{} failed with status {}","messagePattern":"(.+?) failed with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/home.rs","lineNumber":717,"sourceCode":"        bail!(\"git {} failed\", args.join(\" \"));\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())\n}\n\nfn run_command(cmd: &str, args: &[&str], cwd: Option<&Path>) -> Result<()> {\n    let mut command = Command::new(cmd);\n    command.args(args);\n    if let Some(dir) = cwd {\n        command.current_dir(dir);\n    }\n    let status = command\n        .stdin(Stdio::inherit())\n        .stdout(Stdio::inherit())\n        .stderr(Stdio::inherit())\n        .status()\n        .with_context(|| format!(\"failed to run {}\", cmd))?;\n    if !status.success() {\n        bail!(\"{} failed with status {}\", cmd, status);\n    }\n    Ok(())\n}\n\nfn read_internal_repo(config_dir: &Path) -> Result<Option<String>> {\n    let candidates = [config_dir.join(\"home.toml\"), config_dir.join(\".home.toml\")];\n    for path in candidates {\n        if !path.exists() {\n            continue;\n        }\n        let raw = fs::read_to_string(&path)\n            .with_context(|| format!(\"failed to read {}\", path.display()))?;\n        let parsed: HomeConfigFile =\n            toml::from_str(&raw).with_context(|| format!(\"failed to parse {}\", path.display()))?;\n        let from_section = parsed\n            .home\n            .as_ref()\n            .and_then(|h| h.internal_repo.clone().or(h.internal_repo_url.clone()));","sourceCodeStart":699,"sourceCodeEnd":735,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/home.rs#L699-L735","documentation":"run_command is the generic inherit-stdio command runner used by apply_config, ensure_kar_repo, update_repo, clone_repo, and ensure_origin_url. When the spawned command exits non-zero it bails with `<cmd> failed with status <status>`. Unlike git_capture, output is inherited, so the child's own diagnostics are already visible on the terminal.","triggerScenarios":"Any managed command (git clone/pull, apply-config scripts, etc.) spawned via run_command exits with a non-zero status; the error reports the command name and ExitStatus.","commonSituations":"git clone failing due to bad URL, auth failure, or missing network; update_repo pull hitting merge conflicts; an apply_config hook script failing; missing binary on PATH caught at spawn is a separate context error.","solutions":["Read the inherited output above the error for the child's real failure reason","Fix auth/network and retry (e.g. `gh auth login`, check SSH keys)","Run the failing command manually in the same directory to reproduce","Resolve repo conflicts (stash/commit local changes) before update steps"],"exampleFix":"// before\ngit pull   # conflict: local changes\n// after\ngit stash && git pull && git stash pop","handlingStrategy":"try-catch","validationCode":"// check git availability and clean state before managed commands\nlet status = Command::new(\"git\").args([\"-C\", dest, \"status\", \"--porcelain\"]).output()?;\nif !status.status.success() { bail!(\"git status failed; fix repo state first\"); }","typeGuard":null,"tryCatchPattern":"match run_command(...) {\n    Err(e) if e.to_string().contains(\"failed with status\") => {\n        eprintln!(\"{} — see inherited output above for the child's error\", e);\n    }\n    r => r?,\n}","preventionTips":["Keep managed repos clean (commit/stash) before update operations","Verify network and credentials (SSH keys, tokens) before clone/pull","Run managed commands manually once to see their raw output"],"tags":["git","process-exit","subprocess"],"backgroundTag":"command-exited-nonzero","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}