gastownhall/beads · error

clearing remote store %s: %w

Error message

clearing remote store %s: %w

What it means

Wraps an os.RemoveAll failure while emptying the directory that backs a Dolt remote store during 'bd dolt-remote reset-data'. Before resetting, clearDoltFileStore deletes every entry in the remote store directory; if the OS refuses to remove any entry (permissions, file in use, read-only mount), the underlying error is wrapped with the directory path. This aborts the reset so the caller never ends up with a partially reset remote that looks clean.

Source

Thrown at cmd/bd/dolt_remote_reset_data.go:182

	for _, e := range base {
		if !strings.HasPrefix(e, prefix) {
			env = append(env, e)
		}
	}
	return append(env, prefix+merged)
}

// clearDoltFileStore removes the contents of a native Dolt file-store
// directory, keeping the directory itself so the follow-up push can rebuild
// the store in place. The caller has already verified a manifest is present.
func clearDoltFileStore(dir string) error {
	entries, err := os.ReadDir(dir)
	if err != nil {
		return fmt.Errorf("reading remote store %s: %w", dir, err)
	}
	for _, entry := range entries {
		if err := os.RemoveAll(filepath.Join(dir, entry.Name())); err != nil {
			return fmt.Errorf("clearing remote store %s: %w", dir, err)
		}
	}
	return nil
}

var doltRemoteResetDataYes bool

var doltRemoteResetDataCmd = &cobra.Command{
	Use:   "reset-data <name>",
	Short: "Replace a remote's data plane in place after a history squash",
	Long: `Replace a Dolt remote's stored data with a fresh copy of local HEAD.

After a history squash (see the History Bloat recovery runbook), a plain
'bd dolt push --force' re-points the remote's refs but deletes nothing:
Dolt remotes accumulate chunks monotonically, so the remote keeps the full
pre-squash store. This command rebuilds the remote's data plane so it holds
only live chunks:

View on GitHub (pinned to 71377f2769)

Solutions

  1. Stop any running dolt server / bd daemon holding files open, then re-run the reset
  2. Check and fix permissions on the remote store directory (chown/chmod, or run with adequate privileges)
  3. Verify the mount is writable (not read-only, disk not full): df -h and mount flags
  4. Remove the directory contents manually with rm -rf, then retry the reset

Example fix

// before
$ bd dolt-remote reset-data origin
Error: clearing remote store /repo/.beads/dolt: permission denied
// after
$ chown -R $(whoami) /repo/.beads/dolt
$ bd dolt-remote reset-data origin
Defensive patterns

Strategy: validation

Validate before calling

info, err := os.Stat(remoteDir)
if err != nil { return err }
if info.Mode()&0200 == 0 { return fmt.Errorf("remote store %s not writable", remoteDir) }
probe := filepath.Join(remoteDir, ".bd-write-test")
if err := os.WriteFile(probe, nil, 0o644); err != nil { return err }
os.Remove(probe)

Prevention

When it happens

Trigger: Running a reset-data command when an entry under the remote store dir cannot be removed: files owned by another user/root, a running dolt server holding open files on some filesystems, a read-only or full-disk mount, or NFS stale handles.

Common situations: Running bd as a non-root user against a root-owned .beads/dolt remote dir; resetting while a background dolt server or another bd process has the store open; containers with read-only volume mounts; SELinux/AppArmor denials.

Related errors


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