gastownhall/beads · error

failed to persist sync.remote to config.yaml: %w

Error message

failed to persist sync.remote to config.yaml: %w

What it means

After successfully adding the 'origin' remote to the Dolt store, adoptGitOriginRemoteForPush persists sync.remote into .beads/config.yaml via SetYamlConfigInDir. If that write fails, this error wraps the cause so the user knows the remote was added in-memory but the durable config update failed.

Source

Thrown at cmd/bd/dolt.go:482

		return false, nil
	}
	remoteURL := normalizeRemoteURL(originURL)

	if proceed, err := applyAdoptionConsent(remoteURL, policy, optIn); err != nil || !proceed {
		return false, err
	}

	beadsDir := selectedDoltBeadsDir()
	if beadsDir == "" {
		return false, fmt.Errorf("no active beads workspace")
	}

	if err := st.AddRemote(ctx, "origin", remoteURL); err != nil {
		return false, err
	}

	if err := config.SetYamlConfigInDir(beadsDir, "sync.remote", remoteURL); err != nil {
		return false, fmt.Errorf("failed to persist sync.remote to config.yaml: %w", err)
	}
	fmt.Fprintln(os.Stderr, "Committing .beads/config.yaml (sync.remote) under your git identity.")
	commitBeadsConfigForActiveRepo(ctx, "bd: update sync.remote")
	return true, nil
}

// printDivergedHistoryGuidance prints recovery guidance when push/pull fails
// due to diverged local and remote histories.
func printDivergedHistoryGuidance(operation string) {
	fmt.Fprintln(os.Stderr, "")
	fmt.Fprintln(os.Stderr, "Local and remote Dolt histories have diverged.")
	fmt.Fprintln(os.Stderr, "This means the local database and the remote have independent commit")
	fmt.Fprintln(os.Stderr, "histories with no common merge base.")
	fmt.Fprintln(os.Stderr, "")
	fmt.Fprintln(os.Stderr, "Recovery options:")
	fmt.Fprintln(os.Stderr, "")
	fmt.Fprintln(os.Stderr, "  1. Keep remote, discard local (recommended if remote is authoritative):")
	fmt.Fprintln(os.Stderr, "       bd bootstrap              # re-clone from remote")

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped cause; if config.yaml is invalid YAML, fix or regenerate it and retry `bd dolt push`
  2. Ensure .beads is writable by the current user (check permissions, mount flags)
  3. Set sync.remote manually: `bd config set sync.remote <origin-url>` (or edit .beads/config.yaml) then push again
  4. If the Dolt remote was added, verify with `bd dolt remote -v` before re-running to avoid duplicate adoption

Example fix

// before: malformed hand-edited .beads/config.yaml
sync.remote: [origin-url
// after
sync.remote: "https://github.com/org/repo.git"
Defensive patterns

Strategy: validation

Validate before calling

var cfg map[string]any
if data, err := os.ReadFile(filepath.Join(beadsDir, "config.yaml")); err == nil {
  if err := yaml.Unmarshal(data, &cfg); err != nil {
    return fmt.Errorf(".beads/config.yaml is invalid YAML: %w", err)
  }
}
if fi, err := os.Stat(beadsDir); err != nil || !fi.IsDir() { /* check writable */ }

Try / catch

ok, err := adoptGitOriginRemoteForPush(ctx, st, cfg)
if err != nil {
  if strings.Contains(err.Error(), "persist sync.remote") {
    // fix config.yaml permissions/contents, or set sync.remote manually, then retry
  }
  return err
}

Prevention

When it happens

Trigger: `bd dolt push` auto-adoption of origin when the config write fails: read-only .beads directory, malformed/unparsable config.yaml, disk full, or .beads/config.yaml deleted between read and write.

Common situations: config.yaml hand-edited into invalid YAML; running as a user without write permission on .beads; .beads mounted read-only in containers/CI.

Related errors


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