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
- Read the wrapped cause; if config.yaml is invalid YAML, fix or regenerate it and retry `bd dolt push`
- Ensure .beads is writable by the current user (check permissions, mount flags)
- Set sync.remote manually: `bd config set sync.remote <origin-url>` (or edit .beads/config.yaml) then push again
- 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
- Don't hand-edit .beads/config.yaml with tools that break YAML; use `bd config set`
- Keep .beads mounted read-write, especially in containers
- Check file ownership after sudo usage on the repo
- Validate config.yaml parses (any yaml parser) before sync operations
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
- persist sync.remote to config.yaml: %w
- no active beads workspace
- failed to set sync remote: %w
- database not available: %w
- failed to load config: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/f58c88374c83922b.
Report an issue: GitHub.