{"record":{"id":"d40830bd8d7e101f","repo":"gastownhall/beads","slug":"cannot-use-c-directory-q-not-a-directory","errorCode":null,"errorMessage":"cannot use -C directory %q: not a directory","messagePattern":"cannot use -C directory %q: not a directory","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/main.go","lineNumber":809,"sourceCode":"\t// Custom help function with semantic coloring (Tufte-inspired)\n\t// Note: Usage output (shown on errors) is not styled to avoid recursion issues\n\trootCmd.SetHelpFunc(colorizedHelpFunc)\n}\n\nfunc resolveChangeDirBeadsDir(path string) (string, error) {\n\tif strings.TrimSpace(path) == \"\" {\n\t\treturn \"\", nil\n\t}\n\tabsPath, err := filepath.Abs(path)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"cannot resolve -C directory %q: %w\", path, err)\n\t}\n\tinfo, err := os.Stat(absPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"cannot use -C directory %q: %w\", path, err)\n\t}\n\tif !info.IsDir() {\n\t\treturn \"\", fmt.Errorf(\"cannot use -C directory %q: not a directory\", path)\n\t}\n\tbeadsDir := beads.FindBeadsDirFrom(absPath)\n\tif beadsDir == \"\" {\n\t\treturn \"\", fmt.Errorf(\"cannot use -C directory %q: no beads project found\", path)\n\t}\n\treturn beadsDir, nil\n}\n\nfunc applyChangeDirSelection() error {\n\tif strings.TrimSpace(changeDir) == \"\" {\n\t\treturn nil\n\t}\n\tbeadsDir, err := resolveChangeDirBeadsDir(changeDir)\n\tif err != nil {\n\t\treturn HandleError(\"%v\", err)\n\t}\n\tchangeDirEnvSnapshot = make(map[string]envSnapshotValue, 3)\n\tfor _, key := range []string{\"BEADS_DIR\", \"BEADS_DB\", \"BD_DB\"} {","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/main.go#L791-L827","documentation":"After confirming the -C path exists via os.Stat, bd requires it to be a directory (not a regular file, device, etc.). Passing a file path triggers this explicit 'not a directory' error with no wrapped OS error.","triggerScenarios":"`bd -C <path>` where <path> resolves to a regular file (e.g. pointing at .beads/issues.jsonl or config.json instead of the project directory).","commonSituations":"Pointing -C at a file inside the project instead of the project root; shell completion or scripts accidentally expanding to a filename; confusion between the beads dir and its files.","solutions":["Pass the project (or .beads) directory, not a file: `bd -C ./myrepo ...`","Fix the script/completion that expanded to a file path","Use the repository root as the -C value"],"exampleFix":"// before\nbd -C .beads/config.json bd list   # a file\n// after\nbd -C . bd list                     # a directory","handlingStrategy":"validation","validationCode":"info, err := os.Stat(dirFlag)\nif err == nil && !info.IsDir() {\n    return fmt.Errorf(\"-C points at a file, need a directory: %s\", dirFlag)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass directories, not files inside the project","Quote and verify shell expansions before invoking bd","Document that -C takes the project/beads directory path"],"tags":["cli","filesystem","flag-parsing"],"backgroundTag":"not-a-directory","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}