dbt-labs/dbt-core · error · anyhow

`git {}` exited with status {}

Error message

`git {}` exited with status {}

What it means

run_git_os in crates/dbt-ci/src/homebrew/publish.rs spawns a `git` subprocess and bails when it exits with a non-zero status, embedding the full argument list and the exit code in the message. This is the generic wrapper for any git command invoked during the Homebrew publish flow (clone, branch, commit, push, etc.). The underlying failure cause is whatever git printed to stderr before exiting.

Source

Thrown at crates/dbt-ci/src/homebrew/publish.rs:179

        || url.starts_with("../")
}

fn run_git(cwd: Option<&Path>, args: &[&str]) -> Result<()> {
    let argv: Vec<OsString> = args.iter().map(|s| (*s).into()).collect();
    run_git_os(cwd, &argv)
}

fn run_git_os(cwd: Option<&Path>, args: &[OsString]) -> Result<()> {
    let mut cmd = Command::new("git");
    if let Some(d) = cwd {
        cmd.current_dir(d);
    }
    cmd.args(args);
    let status = cmd
        .status()
        .with_context(|| format!("spawn `git {}`", display_argv(args)))?;
    if !status.success() {
        bail!(
            "`git {}` exited with status {}",
            display_argv(args),
            status.code().unwrap_or(-1),
        );
    }
    Ok(())
}

fn run_git_capture(cwd: Option<&Path>, args: &[&str]) -> Result<String> {
    let mut cmd = Command::new("git");
    if let Some(d) = cwd {
        cmd.current_dir(d);
    }
    cmd.args(args)
        .stdout(Stdio::piped())
        .stderr(Stdio::inherit());
    let out = cmd
        .output()

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Re-run with git stderr visible (it is inherited) and read the actual git error line immediately above this message.
  2. Verify the auth token: check scope and expiry; for pushes to GitHub the token needs write access to the tap repository.
  3. Confirm the tap repo URL/branch is correct and exists.
  4. Configure git identity (`git config --global user.name/user.email`) if the failure is on commit.
  5. If on a network-restricted CI runner, check proxy/DNS connectivity to the git host.

Example fix

// before (token without push scope)
env::set_var("HOMEBREW_GITHUB_TOKEN", read_only_token);

// after (use a token with repo write access)
env::set_var("HOMEBREW_GITHUB_TOKEN", token_with_repo_write_scope);
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check git connectivity/auth before publishing
let ok = std::process::Command::new("git")
    .args(["ls-remote", &repo_url])
    .status()
    .map(|s| s.success())
    .unwrap_or(false);
if !ok { eprintln!("git cannot access {repo_url}; fix auth/URL before publish"); }

Try / catch

// the error message embeds args + exit code; surface stderr alongside
match publish() {
    Err(e) if e.to_string().contains("exited with status") => {
        eprintln!("git failed: {e:#}; see stderr above for git's own message");
    }
    Err(e) => return Err(e),
    Ok(v) => v,
}

Prevention

When it happens

Trigger: Any git invocation via run_git_os during publish returning non-zero: pushing to a repository with bad/stale credentials, cloning a tap URL that does not exist, committing with a git identity that is not configured, network failure during push/fetch, or git not accepting the https.extraHeader auth prefix.

Common situations: GitHub token lacking `repo` scope so `git push` is rejected; tap repository renamed or deleted; HTTPS URL used without a valid token causing 403; expired credentials; corporate proxy blocking github.com; missing user.name/user.email for commit.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07). Data as JSON: /api/errors/491b6f031784c300. Report an issue: GitHub.