{"record":{"id":"ea247fed9fd013b0","repo":"gastownhall/beads","slug":"reinitializing-dolt-database-at-s-w","errorCode":null,"errorMessage":"reinitializing dolt database at %s: %w","messagePattern":"reinitializing dolt database at (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/doltserver/manifest_recovery.go","lineNumber":245,"sourceCode":"\t}\n\n\tts := time.Now().UTC().Format(\"20060102T150405Z\")\n\tvar backups []string\n\tfor _, nomsDir := range nomsDirs {\n\t\tdotDolt := filepath.Dir(nomsDir) // .../X/.dolt\n\t\tdbDir := filepath.Dir(dotDolt)   // .../X\n\t\tbackupPath := dotDolt + \".\" + ts + \".corrupt.backup\"\n\n\t\tif err := os.Rename(dotDolt, backupPath); err != nil {\n\t\t\treturn backups, fmt.Errorf(\"backing up corrupt dolt database at %s: %w\", dotDolt, err)\n\t\t}\n\t\tbackups = append(backups, backupPath)\n\n\t\tif err := ensureDoltInit(dbDir); err != nil {\n\t\t\t// Best-effort restore so the user is no worse off than before.\n\t\t\t_ = os.RemoveAll(dotDolt)\n\t\t\t_ = os.Rename(backupPath, dotDolt)\n\t\t\treturn backups[:len(backups)-1], fmt.Errorf(\"reinitializing dolt database at %s: %w\", dbDir, err)\n\t\t}\n\t}\n\treturn backups, nil\n}\n","sourceCodeStart":227,"sourceCodeEnd":250,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/doltserver/manifest_recovery.go#L227-L250","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify `dolt` is installed and on PATH at a compatible version (dolt version); reinstall if needed.","Set dolt global config: dolt config --global --add user.email you@example.com and user.name, then retry.","Check the workspace directory is writable by the bd user.","If init still fails, inspect the wrapped error; the corrupt database is safe at .dolt.<ts>.corrupt.backup for manual inspection or dolt support."],"exampleFix":"// before\n$ bd start  # reinitializing dolt database at myrepo: exec: \"dolt\": executable file not found\n// after\n$ export PATH=$PATH:/usr/local/dolt/bin   # or install dolt\n$ dolt config --global --add user.email you@example.com\n$ bd start","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"dolt\"); err != nil {\n    return fmt.Errorf(\"dolt binary not found on PATH: %w\", err)\n}\nout, err := exec.Command(\"dolt\", \"config\", \"--global\", \"--list\").Output()\nif err != nil || !strings.Contains(string(out), \"user.email\") {\n    return fmt.Errorf(\"dolt global user.email/user.name not configured\")\n}","typeGuard":null,"tryCatchPattern":"if err := ensureDoltInit(dbDir); err != nil {\n    // backup restore already attempted by recoverCorruptManifest\n    return fmt.Errorf(\"reinit failed; corrupt db preserved at %s.corrupt.backup: %w\", dotDolt, err)\n}","preventionTips":["Install dolt and keep it on PATH before running bd","Set dolt global config (user.name/user.email) once per machine","Keep the workspace directory writable by the bd user","Keep the dolt version compatible with the bd release"],"tags":["data-recovery","dolt-init","corruption","configuration"],"backgroundTag":"database-reinit-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}