gastownhall/beads · critical

reinitializing dolt database at %s: %w

Error message

reinitializing dolt database at %s: %w

What it means

recoverCorruptManifest wraps ensureDoltInit(dbDir) failures as "reinitializing dolt database at %s: %w". After backing up the corrupt .dolt directory, bd runs dolt init to create a fresh database; if init fails, it restores the backup (best-effort) and reports this error so the user is no worse off. It means the workspace could not be given a fresh, valid dolt database.

Source

Thrown at internal/doltserver/manifest_recovery.go:245

	}

	ts := time.Now().UTC().Format("20060102T150405Z")
	var backups []string
	for _, nomsDir := range nomsDirs {
		dotDolt := filepath.Dir(nomsDir) // .../X/.dolt
		dbDir := filepath.Dir(dotDolt)   // .../X
		backupPath := dotDolt + "." + ts + ".corrupt.backup"

		if err := os.Rename(dotDolt, backupPath); err != nil {
			return backups, fmt.Errorf("backing up corrupt dolt database at %s: %w", dotDolt, err)
		}
		backups = append(backups, backupPath)

		if err := ensureDoltInit(dbDir); err != nil {
			// Best-effort restore so the user is no worse off than before.
			_ = os.RemoveAll(dotDolt)
			_ = os.Rename(backupPath, dotDolt)
			return backups[:len(backups)-1], fmt.Errorf("reinitializing dolt database at %s: %w", dbDir, err)
		}
	}
	return backups, nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Verify `dolt` is installed and on PATH at a compatible version (dolt version); reinstall if needed.
  2. Set dolt global config: dolt config --global --add user.email you@example.com and user.name, then retry.
  3. Check the workspace directory is writable by the bd user.
  4. If init still fails, inspect the wrapped error; the corrupt database is safe at .dolt.<ts>.corrupt.backup for manual inspection or dolt support.

Example fix

// before
$ bd start  # reinitializing dolt database at myrepo: exec: "dolt": executable file not found
// after
$ export PATH=$PATH:/usr/local/dolt/bin   # or install dolt
$ dolt config --global --add user.email you@example.com
$ bd start
Defensive patterns

Strategy: validation

Validate before calling

if _, err := exec.LookPath("dolt"); err != nil {
    return fmt.Errorf("dolt binary not found on PATH: %w", err)
}
out, err := exec.Command("dolt", "config", "--global", "--list").Output()
if err != nil || !strings.Contains(string(out), "user.email") {
    return fmt.Errorf("dolt global user.email/user.name not configured")
}

Try / catch

if err := ensureDoltInit(dbDir); err != nil {
    // backup restore already attempted by recoverCorruptManifest
    return fmt.Errorf("reinit failed; corrupt db preserved at %s.corrupt.backup: %w", dotDolt, err)
}

Prevention

When it happens

Trigger: ensureDoltInit runs `dolt init` (or equivalent) in the workspace after the corrupt .dolt was moved aside and the dolt binary is missing, not on PATH, an incompatible version, or init fails due to permissions or git-like config requirements (missing user.name/email config).

Common situations: dolt was installed via a version bd no longer finds on PATH after an upgrade; the workspace directory is read-only; dolt requires global config (user.name/user.email) that was never set.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/ea247fed9fd013b0. Report an issue: GitHub.