{"record":{"id":"3e4b265e82c406da","repo":"gastownhall/beads","slug":"dolt-clone-failed-w-output-s","errorCode":null,"errorMessage":"dolt clone failed: %w\nOutput: %s","messagePattern":"dolt clone failed: %w\nOutput: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/bootstrap.go","lineNumber":139,"sourceCode":"\n\tfor attempt := 0; ; attempt++ {\n\t\terr := os.RemoveAll(path)\n\t\tif err == nil || os.IsNotExist(err) {\n\t\t\treturn true, nil\n\t\t}\n\t\tif attempt >= len(failedCloneCleanupRetryDelays) {\n\t\t\treturn true, err\n\t\t}\n\t\ttime.Sleep(failedCloneCleanupRetryDelays[attempt])\n\t}\n}\n\nfunc formatFailedCloneTargetError(cloneErr error, output []byte, cloneTarget string, cleaned bool, cleanupErr error) error {\n\tif cleanupErr == nil && cleaned {\n\t\treturn fmt.Errorf(\"dolt clone failed: %w\\nOutput: %s\\nCleaned up failed clone target %q; fix the clone error above and retry `bd bootstrap`\", cloneErr, output, cloneTarget)\n\t}\n\tif cleanupErr == nil {\n\t\treturn fmt.Errorf(\"dolt clone failed: %w\\nOutput: %s\", cloneErr, output)\n\t}\n\tif !cleaned {\n\t\treturn fmt.Errorf(\"dolt clone failed: %w\\nOutput: %s\\nCould not inspect failed clone target %q before cleanup: %v\\nOn Windows this usually means a dolt or bd process, or antivirus scanner, still has a file handle open under `.dolt/noms/LOCK`. Stop stuck dolt/bd processes, wait a moment, delete the directory manually if it remains, then retry `bd bootstrap`\", cloneErr, output, cloneTarget, cleanupErr)\n\t}\n\treturn fmt.Errorf(\"dolt clone failed: %w\\nOutput: %s\\nCould not clean up failed clone target %q after retrying: %v\\nOn Windows this usually means a dolt or bd process, or antivirus scanner, still has a file handle open under `.dolt/noms/LOCK`. Stop stuck dolt/bd processes, wait a moment, delete the directory manually if it remains, then retry `bd bootstrap`\", cloneErr, output, cloneTarget, cleanupErr)\n}\n\nfunc doltCloneArgs(remoteURL, target string) []string {\n\targs := []string{\"clone\"}\n\tif user := os.Getenv(\"DOLT_REMOTE_USER\"); user != \"\" {\n\t\targs = append(args, \"--user\", user)\n\t}\n\treturn append(args, remoteURL, target)\n}\n\n// BootstrapFromGitRemoteWithDB is deprecated. Use BootstrapFromRemoteWithDB instead.\nfunc BootstrapFromGitRemoteWithDB(ctx context.Context, doltDir, gitRemoteURL, database string) (bool, error) {\n\treturn BootstrapFromRemoteWithDB(ctx, doltDir, gitRemoteURL, database)","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/bootstrap.go#L121-L157","documentation":"This branch of formatFailedCloneTargetError fires when `dolt clone` failed and cleanup of the partial clone target could not even be attempted: os.Lstat of the target's .dolt directory failed with an error other than NotExist (cleaned=false is not reachable here; this is the cleanupErr==nil, cleaned==false path where Lstat reported the .dolt dir absent/non-dir). No cleanup was performed, so the leftover directory may still be on disk.","triggerScenarios":"`dolt clone` fails on a non-pre-existing target, removeFailedCloneTargetWithRetry returns cleaned=false with cleanupErr=nil — i.e. the target has no .dolt subdirectory (or it is not a plain directory), so the function declines to delete it.","commonSituations":"dolt failed so early that it created only an empty or partial target with no .dolt; a symlink or file sits at target/.dolt so cleanup refuses to touch it; unusual filesystem where Lstat metadata is unreliable.","solutions":["Read the Output section to identify and fix the underlying dolt clone failure first.","Inspect the leftover target directory (`ls -la <doltDir>/<db>`); if it is debris, remove it manually with `rm -rf` after verifying it is not a repo you need.","If target/.dolt is a symlink or non-directory, remove that entry specifically and retry.","Retry `bd bootstrap` once the target is clean and the clone root cause is fixed."],"exampleFix":"# before\n$ ls -la .beads/dolt/beads/.dolt   # symlink left by an earlier tool\n$ bd bootstrap                     # clone failed; no cleanup done\n# after\n$ rm -f .beads/dolt/beads/.dolt && rm -rf .beads/dolt/beads\n$ bd bootstrap","handlingStrategy":"try-catch","validationCode":"if fi, err := os.Lstat(filepath.Join(doltDir, db, \".dolt\")); err == nil && !fi.IsDir() {\n    // .dolt is a file/symlink: clean it up before bootstrapping\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"dolt clone failed\") {\n    // manually inspect/remove the leftover target, then retry bootstrap\n    _ = os.RemoveAll(filepath.Join(doltDir, db))\n}","preventionTips":["Avoid placing symlinks or files at .beads/dolt/<db>/.dolt.","Fix the dolt clone's root cause first — the Output section shows it.","Keep bootstrap targets dedicated to bd so cleanup heuristics work as designed."],"tags":["dolt","clone","cleanup","bootstrap"],"backgroundTag":"clone-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}