{"record":{"id":"98f54c4cc9166c6c","repo":"gastownhall/beads","slug":"no-config-yaml-found-in-s-run-bd-init-first","errorCode":null,"errorMessage":"no config.yaml found in %s (run 'bd init' first)","messagePattern":"no config\\.yaml found in (.+?) \\(run 'bd init' first\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/yaml_config.go","lineNumber":294,"sourceCode":"\t}\n\n\treturn setYamlConfigAtPath(configPath, key, value)\n}\n\n// SetYamlConfigInDir sets a configuration value in the config.yaml located in\n// the provided beadsDir, bypassing CWD/worktree discovery. Use this when the\n// caller has already resolved the authoritative workspace and needs to avoid\n// local worktree stubs shadowing the real shared config location.\nfunc SetYamlConfigInDir(beadsDir, key, value string) error {\n\t// Validate specific keys (GH#995)\n\tif err := validateYamlConfigValue(key, value); err != nil {\n\t\treturn err\n\t}\n\n\tconfigPath := filepath.Join(beadsDir, \"config.yaml\")\n\tif _, err := os.Stat(configPath); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"no config.yaml found in %s (run 'bd init' first)\", beadsDir)\n\t\t}\n\t\treturn fmt.Errorf(\"failed to stat config.yaml: %w\", err)\n\t}\n\n\treturn setYamlConfigAtPath(configPath, key, value)\n}\n\nvar userGlobalKeyPrefixes = []string{\"metrics.\"}\n\n// userGlobalExactKeys are per-MACHINE settings that must never be written to\n// the project .beads/config.yaml, which is a git-TRACKED file (see\n// cmd/bd/doctor/gitignore.go: nothing in .beads/.gitignore excludes it). A\n// committed value propagates one machine's answer to every clone that pulls\n// it, which for these keys is worse than having no value at all.\n//\n// node_id is the exemplar: it names the beads STORE that grants leases here,\n// and the reclaim guard (issueops.ReclaimExpiredLeasesInTx) compares it\n// against each lease's granted_node. Commit \"node_id: mini\" and every replica","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/config/yaml_config.go#L276-L312","documentation":"SetYamlConfigInDir writes a key/value into the config.yaml inside a given .beads directory, but only updates existing files — it never creates one. When config.yaml is absent from beadsDir it throws this error telling the user to run 'bd init' first.","triggerScenarios":"Calling SetYamlConfigInDir(dir, key, value) (or bd config set against a project) where os.Stat(filepath.Join(beadsDir, \"config.yaml\")) returns os.IsNotExist — i.e. the .beads directory exists but was never initialized, or the wrong directory was passed.","commonSituations":"Running bd config set in a directory without a prior bd init; pointing bd at a copied/synced .beads dir missing config.yaml; typos in BEADS_DIR or cwd.","solutions":["Run `bd init` in the target directory to create .beads/config.yaml, then retry the config set.","Verify you are in the correct project directory (config.yaml must exist at <dir>/.beads/config.yaml).","If the file was deleted, restore it from version control or another checkout.","Create a minimal empty config.yaml manually if init is not desired, then set the key."],"exampleFix":"// before\nSetYamlConfigInDir(\"/proj/.beads\", \"metrics.enabled\", \"true\") // no config.yaml\n// after\n// run once in /proj:\n//   bd init\nSetYamlConfigInDir(\"/proj/.beads\", \"metrics.enabled\", \"true\")","handlingStrategy":"validation","validationCode":"func ensureInitialized(beadsDir string) error {\n    if _, err := os.Stat(filepath.Join(beadsDir, \"config.yaml\")); os.IsNotExist(err) {\n        return fmt.Errorf(\"run 'bd init' in %s first\", beadsDir)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"err := config.SetYamlConfigInDir(dir, key, value)\nif err != nil && strings.Contains(err.Error(), \"run 'bd init' first\") {\n    if out, initErr := exec.Command(\"bd\", \"init\").CombinedOutput(); initErr != nil {\n        return fmt.Errorf(\"init failed: %v: %s\", initErr, out)\n    }\n    return config.SetYamlConfigInDir(dir, key, value)\n}","preventionTips":["Always run `bd init` after cloning or copying a project that uses bd.","Confirm <dir>/.beads/config.yaml exists before scripted config writes.","Avoid syncing .beads directories with tools that drop config.yaml (dotfile managers, partial rsync).","Check cwd/BEADS_DIR before running bd config set to ensure you target the right project."],"tags":["config","missing-file","initialization"],"backgroundTag":"config-file-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}