{"record":{"id":"e7cad912017ff9f5","repo":"gastownhall/beads","slug":"failed-to-persist-sync-remote-to-config-yaml-v","errorCode":null,"errorMessage":"failed to persist sync.remote to config.yaml: %v","messagePattern":"failed to persist sync\\.remote to config\\.yaml: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init.go","lineNumber":1745,"sourceCode":"\n\t\t\t// The write itself happens once, below this block, through\n\t\t\t// seedInitWorkspaceIdentity; this is where its id is decided.\n\t\t\tbootstrapProjectID = cfg.ProjectID\n\n\t\t\t// Create config.yaml template (prefix is stored in DB, not config.yaml)\n\t\t\tif err := createConfigYaml(beadsDir, false, \"\"); err != nil {\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Warning: failed to create config.yaml: %v\\n\", err)\n\t\t\t\t// Non-fatal - continue anyway\n\t\t\t}\n\n\t\t\t// Persist sync.remote to config.yaml so fresh clones can\n\t\t\t// bootstrap from it (the Dolt database is gitignored).\n\t\t\t// Must run AFTER createConfigYaml which creates the file.\n\t\t\t// Persist the effective remote so future bootstrap and hooks know\n\t\t\t// Dolt, not JSONL, is the cross-machine sync path. Plain git\n\t\t\t// origins are valid here: the first push creates refs/dolt/data.\n\t\t\tif err := persistInitSyncRemote(beadsDir, initRemote, syncURL, syncFromRemote, syncURLFromConfig, syncURLFromGitOrigin); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to persist sync.remote to config.yaml: %v\", err)\n\t\t\t}\n\n\t\t\t// Enable shared server mode if requested via flag OR env var (GH#2377).\n\t\t\t// Persist to config.yaml so the project continues working without the env var.\n\t\t\tif sharedServer || doltserver.IsSharedServerMode() {\n\t\t\t\tif err := config.SetYamlConfig(\"dolt.shared-server\", \"true\"); err != nil {\n\t\t\t\t\tfmt.Fprintf(os.Stderr, \"Warning: failed to enable shared server mode: %v\\n\", err)\n\t\t\t\t} else if !quiet {\n\t\t\t\t\tfmt.Printf(\"  %s Shared server mode enabled\\n\", ui.RenderPass(\"✓\"))\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif debugMode {\n\t\t\t\tif err := config.SetYamlConfig(\"dolt.debug\", \"true\"); err != nil {\n\t\t\t\t\tfmt.Fprintf(os.Stderr, \"Warning: failed to persist dolt.debug: %v\\n\", err)\n\t\t\t\t} else if !quiet {\n\t\t\t\t\tserverDir := doltserver.ResolveServerDir(beadsDir)\n\t\t\t\t\tfmt.Printf(\"  %s Debug mode enabled\\n\", ui.RenderPass(\"✓\"))","sourceCodeStart":1727,"sourceCodeEnd":1763,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init.go#L1727-L1763","documentation":"When an initial remote is configured, `bd init` persists the effective sync.remote (and related sync URL state) into .beads/config.yaml via persistInitSyncRemote. If writing the YAML config fails, initialization aborts with this error.","triggerScenarios":"persistInitSyncRemote(...) returns an error (config.yaml missing/unreadable, YAML marshal or write failure) during `bd init` with a --remote/derived remote present; runs after createConfigYaml.","commonSituations":"config.yaml is read-only or owned by another user, disk full, .beads/config.yaml was hand-edited into invalid YAML, or an editor/tool made the file immutable.","solutions":["Check .beads/config.yaml exists and is writable: ls -la .beads/config.yaml","Validate/fix the YAML by hand (or delete it and re-run bd init to regenerate)","Fix ownership/permissions: chown $USER .beads/config.yaml; chmod 644 .beads/config.yaml","Free disk space if the write failed with ENOSPC"],"exampleFix":"// before (read-only file)\n-r--r--r-- .beads/config.yaml\n// after\n$ chmod 644 .beads/config.yaml\n$ bd init ...","handlingStrategy":"validation","validationCode":"cfg=.beads/config.yaml\nif [ -f \"$cfg\" ]; then\n  [ -w \"$cfg\" ] || chmod 644 \"$cfg\"\n  python3 -c \"import yaml,sys; yaml.safe_load(open('$cfg'))\" || echo \"invalid YAML\"\nfi","typeGuard":null,"tryCatchPattern":"bd init ... || { rc=$?; ls -la .beads/config.yaml; exit $rc; }","preventionTips":["Never make config.yaml read-only or immutable (chattr +i)","Validate YAML after hand edits","Keep .beads writable by the running user","Watch disk space before init"],"tags":["config","yaml","init"],"backgroundTag":"config-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}