{"record":{"id":"90b1e9b6e69a1164","repo":"gastownhall/beads","slug":"cannot-use-c-directory-q-w","errorCode":null,"errorMessage":"cannot use -C directory %q: %w","messagePattern":"cannot use -C directory %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/main.go","lineNumber":806,"sourceCode":"\trootCmd.AddGroup(&cobra.Group{ID: \"maint\", Title: \"Maintenance:\"})\n\trootCmd.AddGroup(&cobra.Group{ID: \"advanced\", Title: \"Integrations & Advanced:\"})\n\n\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)","sourceCodeStart":788,"sourceCodeEnd":824,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/main.go#L788-L824","documentation":"resolveChangeDirBeadsDir stats the resolved -C path; if os.Stat fails (path does not exist, permission denied, or a broken symlink), bd rejects the flag with 'cannot use -C directory' wrapping the OS error.","triggerScenarios":"`bd -C <path> <command>` where the path does not exist, the user lacks traverse permissions, or the path is a dangling symlink; also fires before the not-a-directory check whenever Stat errors.","commonSituations":"Typo in the -C path; running from a different cwd than expected in scripts; deleted or renamed project directory; permission issues in containers/CI.","solutions":["Verify the path exists: ls <path>","Check for typos and that you are invoking from the expected cwd","Fix permissions or use a path you can access","Remove or repair broken symlinks"],"exampleFix":"// before\nbd -C ./projcts bd list   # typo, dir doesn't exist\n// after\nls ./projects             # confirm it exists\nbd -C ./projects bd list","handlingStrategy":"validation","validationCode":"info, err := os.Stat(dirFlag)\nif err != nil || !info.IsDir() {\n    return fmt.Errorf(\"-C must be an existing directory: %s\", dirFlag)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["ls the -C target before running in scripts","Use repo roots as -C values, never files","Watch for broken symlinks in CI checkouts"],"tags":["cli","filesystem","flag-parsing"],"backgroundTag":"directory-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}