{"record":{"id":"f2087fbbf30596de","repo":"gastownhall/beads","slug":"cannot-resolve-c-directory-q-w","errorCode":null,"errorMessage":"cannot resolve -C directory %q: %w","messagePattern":"cannot resolve -C directory %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/main.go","lineNumber":802,"sourceCode":"\trootCmd.AddGroup(&cobra.Group{ID: \"setup\", Title: \"Setup & Configuration:\"})\n\t// NOTE: Many maintenance commands (clean, cleanup, compact, validate, repair-deps)\n\t// should eventually be consolidated into 'bd doctor' and 'bd doctor --fix' to simplify\n\t// the user experience. The doctor command can detect issues and offer fixes interactively.\n\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","sourceCodeStart":784,"sourceCodeEnd":820,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/main.go#L784-L820","documentation":"When the -C flag is given, bd resolves the provided path to an absolute directory to locate the beads project. If filepath.Abs itself fails (rare OS-level path resolution error), the path cannot be resolved and this wrapped error is returned before any filesystem probing.","triggerScenarios":"Passing a -C value whose absolute-path resolution fails — typically only with pathological paths (e.g. extremely long paths exceeding OS limits on some systems) or platform-specific path errors.","commonSituations":"Very long path components on Linux; malformed path bytes; embedded NUL or invalid characters in the path argument from scripted invocation.","solutions":["Re-run with a simpler/shorter relative path (e.g. cd closer to the project first)","Check the path for invalid characters","Verify OS path-length limits and shorten the directory chain if needed"],"exampleFix":"// before\nbd -C /very/long/path/.../repo bd list\n// after\ncd /very/long/path/.../repo\nbd list   # or use a shorter -C path","handlingStrategy":"validation","validationCode":"if _, err := filepath.Abs(dirFlag); err != nil {\n    return fmt.Errorf(\"invalid -C path: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer short, simple relative paths for -C","Sanitize paths passed from scripts","Stay under OS path-length limits"],"tags":["cli","filesystem","flag-parsing"],"backgroundTag":"invalid-directory-path","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}