nikivdev/code · error
{} failed with status {}
Error message
{} failed with status {} What it means
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.
Source
Thrown at src/home.rs:717
bail!("git {} failed", args.join(" "));
}
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
}
fn run_command(cmd: &str, args: &[&str], cwd: Option<&Path>) -> Result<()> {
let mut command = Command::new(cmd);
command.args(args);
if let Some(dir) = cwd {
command.current_dir(dir);
}
let status = command
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status()
.with_context(|| format!("failed to run {}", cmd))?;
if !status.success() {
bail!("{} failed with status {}", cmd, status);
}
Ok(())
}
fn read_internal_repo(config_dir: &Path) -> Result<Option<String>> {
let candidates = [config_dir.join("home.toml"), config_dir.join(".home.toml")];
for path in candidates {
if !path.exists() {
continue;
}
let raw = fs::read_to_string(&path)
.with_context(|| format!("failed to read {}", path.display()))?;
let parsed: HomeConfigFile =
toml::from_str(&raw).with_context(|| format!("failed to parse {}", path.display()))?;
let from_section = parsed
.home
.as_ref()
.and_then(|h| h.internal_repo.clone().or(h.internal_repo_url.clone()));View on GitHub (pinned to a747e741ae)
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
Example fix
// before git pull # conflict: local changes // after git stash && git pull && git stash pop
Defensive patterns
Strategy: try-catch
Validate before calling
// check git availability and clean state before managed commands
let status = Command::new("git").args(["-C", dest, "status", "--porcelain"]).output()?;
if !status.status.success() { bail!("git status failed; fix repo state first"); } Try / catch
match run_command(...) {
Err(e) if e.to_string().contains("failed with status") => {
eprintln!("{} — see inherited output above for the child's error", e);
}
r => r?,
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- git {} failed
- git {} failed: {}
- Lin.app is not running
- pbcopy exited with status {}
- AI task '{}' failed with status {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/0885f1cde66ecf47.
Report an issue: GitHub.