{"record":{"id":"34033d068b7717d3","repo":"gastownhall/beads","slug":"failed-to-create-user-config-yaml-w","errorCode":null,"errorMessage":"failed to create user config.yaml: %w","messagePattern":"failed to create user config\\.yaml: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/yaml_config.go","lineNumber":499,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc SetUserYamlConfig(key, value string) error {\n\tif err := validateYamlConfigValue(key, value); err != nil {\n\t\treturn err\n\t}\n\tconfigPath, err := UserConfigYamlPath()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := os.MkdirAll(filepath.Dir(configPath), 0o755); err != nil {\n\t\treturn fmt.Errorf(\"failed to create user config directory: %w\", err)\n\t}\n\tif _, err := os.Stat(configPath); os.IsNotExist(err) {\n\t\tif err := os.WriteFile(configPath, []byte{}, 0o600); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create user config.yaml: %w\", err)\n\t\t}\n\t} else if err != nil {\n\t\treturn fmt.Errorf(\"failed to stat user config.yaml: %w\", err)\n\t}\n\treturn setYamlConfigAtPath(configPath, key, value)\n}\n\nfunc setYamlConfigAtPath(configPath, key, value string) error {\n\n\t// Normalize key to canonical yaml format\n\tnormalizedKey := normalizeYamlKey(key)\n\n\t// Read existing config\n\tcontent, err := os.ReadFile(configPath) //nolint:gosec // configPath is from findProjectConfigYaml\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to read config.yaml: %w\", err)\n\t}\n","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/config/yaml_config.go#L481-L517","documentation":"When the user config.yaml does not yet exist, SetUserYamlConfig creates an empty file with os.WriteFile(path, []byte{}, 0o600) to establish the owner-private posture before writing keys. Failure of this initial creation is wrapped as 'failed to create user config.yaml'.","triggerScenarios":"First-time bd config set for a user with no config.yaml, where os.WriteFile fails: parent dir permissions changed between MkdirAll and write, read-only filesystem, quota/ENOSPC, or file lock on Windows.","commonSituations":"Fresh machine/CI container where HOME is not writable; antivirus holding a lock on the newly created file; disk quota exhausted on first write.","solutions":["Verify the parent directory (~/.beads) is writable: touch ~/.beads/.probe; fix with chown/chmod if not.","Free disk space / raise quota if ENOSPC.","Retry after closing programs locking the file (editors, AV, sync clients like Dropbox).","Pre-create the file yourself with correct mode: install -m 600 /dev/null ~/.beads/config.yaml, then rerun."],"exampleFix":"// before\nbd config set metrics.enabled true   // ENOSPC: failed to create user config.yaml\n// after\ndf -h ~/.beads          # full -> clean space\nbd config set metrics.enabled true","handlingStrategy":"validation","validationCode":"p := filepath.Join(home, \".beads\", \"config.yaml\")\nif _, err := os.Stat(p); os.IsNotExist(err) {\n    if err := unix.Access(filepath.Dir(p), unix.W_OK); err != nil {\n        return fmt.Errorf(\"cannot create config.yaml in %s: %w\", filepath.Dir(p), err)\n    }\n}","typeGuard":null,"tryCatchPattern":"err := config.SetUserYamlConfig(key, value)\nif err != nil && strings.Contains(err.Error(), \"failed to create user config.yaml\") {\n    _ = os.MkdirAll(filepath.Dir(userConfigPath), 0o755)\n    f, cerr := os.OpenFile(userConfigPath, os.O_CREATE|os.O_WRONLY, 0o600)\n    if cerr != nil { return cerr }\n    f.Close()\n    return config.SetUserYamlConfig(key, value)\n}","preventionTips":["Ensure HOME is writable before first-run bd config commands.","Free disk space / watch quotas on fresh environments.","Close file-locking apps (editors, sync clients, AV) on Windows.","Pre-create ~/.beads/config.yaml with mode 600 in provisioning scripts."],"tags":["config","filesystem","create","permissions"],"backgroundTag":"config-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}