{"record":{"id":"46d02569baaa4ef6","repo":"gastownhall/beads","slug":"failed-to-write-config-yaml-w","errorCode":null,"errorMessage":"failed to write config.yaml: %w","messagePattern":"failed to write config\\.yaml: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init_templates.go","lineNumber":21,"sourceCode":"import (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n)\n\n// createConfigYaml creates the config.yaml template in the specified directory\n// In --no-db mode, the prefix is saved here since there's no database to store it.\nfunc createConfigYaml(beadsDir string, noDbMode bool, prefix string) error {\n\tconfigYamlPath := filepath.Join(beadsDir, \"config.yaml\")\n\n\t// Skip if already exists\n\tif _, err := os.Stat(configYamlPath); err == nil {\n\t\treturn nil\n\t}\n\n\tbody := renderInitConfigYAML(prefix, noDbMode)\n\tif err := os.WriteFile(configYamlPath, body, 0600); err != nil {\n\t\treturn fmt.Errorf(\"failed to write config.yaml: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc renderInitConfigYAML(prefix string, noDbMode bool) []byte {\n\tnoDbLine := \"# no-db: false\"\n\tif noDbMode {\n\t\tnoDbLine = \"no-db: true  # JSONL-only mode, no database\"\n\t}\n\n\tprefixLine := \"# issue-prefix: \\\"\\\"\"\n\tif noDbMode && prefix != \"\" {\n\t\tprefixLine = fmt.Sprintf(\"issue-prefix: %q\", prefix)\n\t}\n\n\tbody := fmt.Sprintf(`# Beads Configuration File\n# This file configures default behavior for all bd commands in this repository","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init_templates.go#L3-L39","documentation":"createConfigYaml writes the bootstrap .beads/config.yaml (rendered from prefix/noDbMode) only if the file does not already exist. If os.WriteFile fails, the error is wrapped as 'failed to write config.yaml: %w'. Called by finalizeSyncedBootstrap during init, so init cannot finish provisioning the workspace config.","triggerScenarios":"Running `bd init` (synced bootstrap path) when os.WriteFile on the config.yaml path fails: parent directory missing, permission denied, path is a directory, read-only filesystem, or disk full.","commonSituations":".beads directory not created or wrong owner; running under a user without write access to the repo; .beads/config.yaml exists as a directory (odd checkouts); CI runs on a read-only checkout.","solutions":["Ensure the parent directory exists and is writable (mkdir -p .beads; chown if needed)","Check whether config.yaml path is actually a directory or locked; remove/fix it","Free disk space if the disk is full","Re-run `bd init` after fixing permissions"],"exampleFix":"// before\n$ bd init\nfailed to write config.yaml: open /repo/.beads/config.yaml: permission denied\n// after\n$ mkdir -p .beads && chmod u+w .beads\n$ bd init","handlingStrategy":"validation","validationCode":"dir := filepath.Join(beadsDir, \"config.yaml\")\nif fi, err := os.Stat(filepath.Dir(dir)); err != nil || !fi.IsDir() {\n    return fmt.Errorf(\".beads directory missing or invalid\")\n}\nif fi, err := os.Stat(dir); err == nil && fi.IsDir() {\n    return fmt.Errorf(\"config.yaml path is a directory\")\n}","typeGuard":null,"tryCatchPattern":"if err := createConfigYaml(prefix, noDbMode); err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) {\n        log.Printf(\"config write blocked at %s: %v\", pe.Path, pe.Err)\n    }\n    return err\n}","preventionTips":["Ensure .beads exists and is writable before init (mkdir -p .beads)","Never create files/dirs named config.yaml inside .beads","Watch for read-only mounts in CI runners","Fix ownership when .beads was created by another user (sudo)"],"tags":["filesystem","init","config","permissions"],"backgroundTag":"file-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}