{"record":{"id":"52bfcfbacef90fea","repo":"gastownhall/beads","slug":"reading-remote-store-s-w","errorCode":null,"errorMessage":"reading remote store %s: %w","messagePattern":"reading remote store (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/dolt_remote_reset_data.go","lineNumber":178,"sourceCode":"\tbase := os.Environ()\n\tmerged := githooksenv.AppendParameter(githooksenv.Extract(base), githooksenv.NoHooksParam)\n\tenv := make([]string, 0, len(base)+1)\n\tprefix := githooksenv.ParametersEnv + \"=\"\n\tfor _, e := range base {\n\t\tif !strings.HasPrefix(e, prefix) {\n\t\t\tenv = append(env, e)\n\t\t}\n\t}\n\treturn append(env, prefix+merged)\n}\n\n// clearDoltFileStore removes the contents of a native Dolt file-store\n// directory, keeping the directory itself so the follow-up push can rebuild\n// the store in place. The caller has already verified a manifest is present.\nfunc clearDoltFileStore(dir string) error {\n\tentries, err := os.ReadDir(dir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading remote store %s: %w\", dir, err)\n\t}\n\tfor _, entry := range entries {\n\t\tif err := os.RemoveAll(filepath.Join(dir, entry.Name())); err != nil {\n\t\t\treturn fmt.Errorf(\"clearing remote store %s: %w\", dir, err)\n\t\t}\n\t}\n\treturn nil\n}\n\nvar doltRemoteResetDataYes bool\n\nvar doltRemoteResetDataCmd = &cobra.Command{\n\tUse:   \"reset-data <name>\",\n\tShort: \"Replace a remote's data plane in place after a history squash\",\n\tLong: `Replace a Dolt remote's stored data with a fresh copy of local HEAD.\n\nAfter a history squash (see the History Bloat recovery runbook), a plain\n'bd dolt push --force' re-points the remote's refs but deletes nothing:","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/dolt_remote_reset_data.go#L160-L196","documentation":"clearDoltFileStore removes the contents of a native Dolt file-store directory (keeping the directory itself) so a follow-up push can rebuild it, and this error wraps an os.ReadDir failure on that directory. The caller has already verified a manifest exists, so the directory existed moments earlier — the failure is almost always permissions or the directory disappearing mid-operation.","triggerScenarios":"During bd dolt remote reset-data on a classified Dolt file store, os.ReadDir(dir) fails after the manifest check: permission denied, the directory was removed by a concurrent process, or an I/O error.","commonSituations":"Remote store owned by another user/root (e.g. created by a Dolt server); concurrent reset or cleanup job deleting the store between classification and clearing; filesystem mounted read-only.","solutions":["Fix ownership/permissions on the store directory so the running user can list and delete its entries","Ensure no concurrent process (Dolt server, another bd run) is touching the store; stop it and retry","Verify the filesystem is writable and not mounted read-only","If the store was deleted mid-run, re-run the command from the start so classification re-runs"],"exampleFix":"// before\n$ ls -ld /srv/dolt/repo  # owned by doltserver\n// after\n$ sudo chown -R $USER /srv/dolt/repo && bd dolt remote reset-data origin","handlingStrategy":"retry","validationCode":"if info, err := os.Stat(dir); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"store %s missing or not a directory\", dir)\n}\nif !writable(dir) { return fmt.Errorf(\"store %s not writable\", dir) }","typeGuard":null,"tryCatchPattern":"if err := clearDoltFileStore(dir); err != nil {\n    // likely transient or permission issue: stop concurrent writers, then retry once\n    return fmt.Errorf(\"store left partially cleared; re-run reset-data: %w\", err)\n}","preventionTips":["Stop Dolt servers and other bd processes before reset-data on a file store","Ensure the running user owns the store directory","Re-run the full reset-data flow (re-classification) if a clear is interrupted"],"tags":["filesystem","permissions","dolt","remote"],"backgroundTag":"directory-read-permission-denied","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}