gastownhall/beads · error
git rev-parse timed out after %s
Error message
git rev-parse timed out after %s
What it means
gitIndexLockPath runs `git rev-parse --git-dir` under a context timeout to locate the git directory for the lock preflight. If rev-parse exceeds gitAddTimeout, this error is returned and the lock check is abandoned, failing the git add preflight.
Source
Thrown at cmd/bd/export_auto.go:894
}
if err != nil {
if trimmed := strings.TrimSpace(string(out)); trimmed != "" {
return fmt.Errorf("%w: %s", err, trimmed)
}
return err
}
return nil
}
func gitIndexLockPath(path string, env []string) (string, error) {
ctx, cancel := context.WithTimeout(context.Background(), gitAddTimeout)
defer cancel()
cmd := exec.CommandContext(ctx, "git", "rev-parse", "--git-dir")
cmd.Dir = filepath.Dir(path)
cmd.Env = env
out, err := cmd.CombinedOutput()
if ctx.Err() == context.DeadlineExceeded {
return "", fmt.Errorf("git rev-parse timed out after %s", gitAddTimeout)
}
if err != nil {
if trimmed := strings.TrimSpace(string(out)); trimmed != "" {
return "", fmt.Errorf("%w: %s", err, trimmed)
}
return "", err
}
gitDir := strings.TrimSpace(string(out))
if gitDir == "" {
return "", nil
}
if !filepath.IsAbs(gitDir) {
gitDir = filepath.Join(filepath.Dir(path), gitDir)
}
return filepath.Join(gitDir, "index.lock"), nil
}
// scrubGitHookEnv returns env with the GIT_* variables that can poisonView on GitHub (pinned to 71377f2769)
Solutions
- Retry the auto-export once the transient slowness clears
- Investigate filesystem/git health (df, iostat, stray git processes) in the repo
- Raise gitAddTimeout if the environment is consistently slow; otherwise stage manually with `git add`
Example fix
// before // git rev-parse timed out after 10s // after # verify repo is responsive git rev-parse --git-dir bd sync
Defensive patterns
Strategy: retry
Validate before calling
// Confirm git itself is responsive before automating
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
out, err := exec.CommandContext(ctx, "git", "rev-parse", "--git-dir").Output()
if err != nil || len(bytes.TrimSpace(out)) == 0 {
fmt.Println("git not responsive or not a repo; abort auto-export")
} Try / catch
if err := autoExport(); err != nil && strings.Contains(err.Error(), "rev-parse timed out") {
// Transient slowness — retry after backoff or stage manually
time.Sleep(5 * time.Second)
runCmd("git", "add", ".beads/issues.jsonl")
} Prevention
- Monitor filesystem latency on CI runners hosting large repos
- Avoid competing heavy git operations during auto-export windows
- Use local clones rather than network mounts for automated bd runs
- Re-run with a longer timeout for very large worktrees
When it happens
Trigger: `git rev-parse --git-dir` spawned by gitIndexLockPath (from gitAddFile during auto-export) hits context.DeadlineExceeded — slow filesystem or hung git subprocess.
Common situations: NFS/network-mounted repos, overloaded CI machines, git waiting on credential/maintenance hooks, or heavy disk I/O delaying even rev-parse.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- git ls-remote %s failed: %s: %w
- git add timed out after %s
- failed to resolve target git directory: %w
- failed to resolve target common git directory: %w
- target HEAD does not resolve to a commit: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/781abee2e36c1681.
Report an issue: GitHub.