{"record":{"id":"391b1c2b9c98a380","repo":"gastownhall/beads","slug":"ensureproxiedserverconfig-mkdir-s-w","errorCode":null,"errorMessage":"ensureProxiedServerConfig: mkdir %s: %w","messagePattern":"ensureProxiedServerConfig: mkdir (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/proxied_server.go","lineNumber":138,"sourceCode":"\tpath, isCustom, err := resolveProxiedServerConfigPath(beadsDir)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif isCustom {\n\t\tinfo, err := os.Stat(path)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"ensureProxiedServerConfig: custom config %s: %w\", path, err)\n\t\t}\n\t\tif !info.Mode().IsRegular() {\n\t\t\treturn \"\", fmt.Errorf(\"ensureProxiedServerConfig: custom config %s: not a regular file\", path)\n\t\t}\n\t\treturn path, nil\n\t}\n\n\troot := filepath.Dir(path)\n\tif err := os.MkdirAll(root, config.BeadsDirPerm); err != nil {\n\t\treturn \"\", fmt.Errorf(\"ensureProxiedServerConfig: mkdir %s: %w\", root, err)\n\t}\n\n\tswitch _, err := os.Stat(path); {\n\tcase err == nil:\n\t\treturn path, nil\n\tcase !os.IsNotExist(err):\n\t\treturn \"\", fmt.Errorf(\"ensureProxiedServerConfig: stat %s: %w\", path, err)\n\t}\n\n\tport, err := proxy.PickFreePort()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"ensureProxiedServerConfig: pick free port: %w\", err)\n\t}\n\n\tbody, err := renderProxiedServerConfig(port)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"ensureProxiedServerConfig: render YAML: %w\", err)\n\t}","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/proxied_server.go#L120-L156","documentation":"When no custom config is supplied, ensureProxiedServerConfig creates the config's parent directory with config.BeadsDirPerm before writing the generated YAML. This error wraps os.MkdirAll failure for that parent directory. It means bd could not create or traverse a directory component on the way to the config file.","triggerScenarios":"os.MkdirAll(filepath.Dir(path), config.BeadsDirPerm) fails because a path component exists as a non-directory (e.g. `~/.beads` is a regular file), the parent is read-only, or permission denies traversal (unreadable $HOME, root-owned dir, restricted sandbox).","commonSituations":"$HOME not writable (CI containers running as non-root with odd HOME); ~/.beads accidentally created as a file; read-only container filesystem or read-only $HOME mount; NFS/network home with permission quirks; sandboxed environments blocking writes outside the workspace.","solutions":["Inspect the wrapped os error: if it is 'not a directory', check whether an ancestor path component (like ~/.beads) is a file and remove/rename it (`ls -ld ~/.beads`).","Check write/traverse permissions on each ancestor: `ls -ld $(dirname -a <path>)` and `chmod u+w` the directory that denies writes.","If running in a container or sandbox, ensure $HOME (or BEADS_DIR equivalent) points to a writable location, or run with appropriate user/permissions.","Free disk space / fix full-device conditions if the error is ENOSPC.","As a last resort pass a custom config path on a writable filesystem instead of the default location."],"exampleFix":"// before\n$ ls -ld ~/.beads\n-rw-r--r-- 1 user user 0 ~/.beads      # a file where a dir is required\n// after\n$ rm ~/.beads && bd serve                # bd recreates ~/.beads/ with BeadsDirPerm","handlingStrategy":"validation","validationCode":"dir := filepath.Dir(cfgPath)\nif st, err := os.Stat(dir); err == nil && !st.IsDir() {\n\treturn fmt.Errorf(\"%s exists but is not a directory\", dir)\n}\nif err := os.MkdirAll(dir, 0o755); err != nil {\n\treturn err\n}","typeGuard":"func isWritableDir(path string) bool {\n\tinfo, err := os.Stat(path)\n\tif err != nil || !info.IsDir() {\n\t\treturn false\n\t}\n\tf, err := os.CreateTemp(path, \".wtest*\")\n\tif err != nil {\n\t\treturn false\n\t}\n\tf.Close()\n\tos.Remove(f.Name())\n\treturn true\n}","tryCatchPattern":null,"preventionTips":["Ensure $HOME (or the configured beads dir) is writable by the user running bd, especially in containers and CI.","Check periodically that ~/.beads is a directory, not a file (a stray file blocks MkdirAll).","In sandboxes, pre-create the beads directory at image-build time rather than at runtime.","Watch disk space and inode availability on the volume hosting ~/.beads."],"tags":["go","filesystem","permissions","mkdir","proxied-server"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}