{"record":{"id":"7640f8acb4f93637","repo":"gastownhall/beads","slug":"dolt-clone-failed-w-output-s-could-not-inspect","errorCode":null,"errorMessage":"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`","messagePattern":"dolt clone failed: %w\nOutput: (.+?)\nCould not inspect failed clone target %q before cleanup: (.+?)\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`","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/bootstrap.go","lineNumber":142,"sourceCode":"\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)\n}\n\n// pathExists reports whether path exists (of any type), without following","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/bootstrap.go#L124-L160","documentation":"This branch of formatFailedCloneTargetError fires when `dolt clone` failed AND cleanup of the partial clone target could not even be inspected: os.Lstat of the target's .dolt returned a non-NotExist error. The message is Windows-centric — it almost always means another process (dolt, bd, or an antivirus scanner) still holds a handle under .dolt/noms/LOCK, so the partial clone is left in place with remediation instructions.","triggerScenarios":"`dolt clone` fails, then removeFailedCloneTargetWithRetry's os.Lstat(<target>/.dolt) errors with something other than NotExist (permission denied, sharing violation, I/O error) — classic Windows file-locking on .dolt/noms/LOCK right after a failed dolt process exits.","commonSituations":"Windows machines where Defender or another AV scans the freshly written .dolt files immediately after a failed clone; a lingering dolsql/dolt process holding the noms LOCK; OneDrive/Dropbox sync locking .beads paths; the repo living on a network share with handle delays.","solutions":["Wait a few seconds and retry `bd bootstrap` — the error text's cleanup retry loop (50ms–500ms) may simply need longer for the lock to release.","Kill any stuck dolt/bd processes (Task Manager or `taskkill /F /IM dolt.exe`) that still hold handles under the target directory.","Add an antivirus/Defender exclusion for the workspace's .beads directory so the scanner stops locking .dolt/noms/LOCK.","If the partial directory remains, delete it manually (`rm -rf .beads/dolt/<db>` or Explorer) once handles are released, then retry.","Move the workspace off network-synced storage (OneDrive/Dropbox/SMB share) to a local disk if locking recurs."],"exampleFix":"# before (Windows): clone failed, LOCK held\n$ bd bootstrap\n#   Could not inspect failed clone target ... .dolt/noms/LOCK\n# after: release the handle, clean up, retry\n$ taskkill /F /IM dolt.exe\n$ rmdir /s /q .beads\\dolt\\beads\n$ bd bootstrap","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"Could not inspect failed clone target\") {\n    time.Sleep(2 * time.Second) // let AV/scanner release .dolt/noms/LOCK\n    // retry bootstrap or clean up manually\n}","preventionTips":["Add antivirus exclusions for the workspace .beads directory (Windows/Defender).","Keep the repo on a local disk, not OneDrive/Dropbox/SMB-synced storage.","Ensure no long-running dolsql/dolt process holds the database directory during bootstrap.","Retry after a short delay — the library's built-in retries (up to ~900ms) may not outlast the lock."],"tags":["dolt","clone","windows","file-lock","bootstrap"],"backgroundTag":"file-locked-by-another-process","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}