{"record":{"id":"86053bde5421fc0e","repo":"plandex-ai/plandex","slug":"no-project-root-found","errorCode":null,"errorMessage":"no project root found","messagePattern":"no project root found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/fs/paths.go","lineNumber":19,"sourceCode":"package fs\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"plandex-cli/types\"\n\t\"strings\"\n\t\"sync\"\n\n\tshared \"plandex-shared\"\n\n\tignore \"github.com/sabhiram/go-gitignore\"\n)\n\nfunc GetProjectPaths(baseDir string) (*types.ProjectPaths, error) {\n\tif ProjectRoot == \"\" {\n\t\treturn nil, fmt.Errorf(\"no project root found\")\n\t}\n\n\treturn GetPaths(baseDir, ProjectRoot)\n}\n\nfunc GetPaths(baseDir, currentDir string) (*types.ProjectPaths, error) {\n\tignored, err := GetPlandexIgnore(currentDir)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tallPaths := map[string]bool{}\n\tactivePaths := map[string]bool{}\n\n\tallDirs := map[string]bool{}\n\tactiveDirs := map[string]bool{}\n\tgitIgnoredDirs := map[string]bool{}","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/fs/paths.go#L1-L37","documentation":"GetProjectPaths resolves project file paths relative to fs.ProjectRoot, but returns 'no project root found' when that package-level variable is empty. ProjectRoot is normally initialized when the CLI/REPL loads a workspace; calling GetProjectPaths before that initialization (or outside a valid project directory) yields this error.","triggerScenarios":"Calling GetProjectPaths (directly or via MustApplyPlanAttempt, MustLoadContext, Build, runRepl, update) while fs.ProjectRoot == \"\": running the tool outside a project directory, invoking library functions before project discovery runs, or initialization code failing silently earlier.","commonSituations":"Running CLI commands from $HOME or a directory with no project marker; embedding the library and calling Build/MustLoadContext without setting fs.ProjectRoot; a failed earlier root-detection step leaving the variable unset.","solutions":["Run the command from inside a project directory that root detection recognizes (contains the expected marker file)","Ensure the project-discovery/initialization step ran before calling GetProjectPaths — call the root-detection entry point first if using this as a library","Check earlier startup logs for a silent failure in root detection","If Programmatic use is intended, set fs.ProjectRoot explicitly before calling GetProjectPaths"],"exampleFix":"// before\npaths, err := fs.GetProjectPaths(baseDir) // panics with 'no project root found'\n// after\nif fs.ProjectRoot == \"\" {\n\troot, rerr := fs.DetectProjectRoot(cwd)\n\tif rerr != nil {\n\t\treturn fmt.Errorf(\"cannot locate project root: %w\", rerr)\n\t}\n\tfs.ProjectRoot = root\n}\npaths, err := fs.GetProjectPaths(baseDir)","handlingStrategy":"validation","validationCode":"// run before calling GetProjectPaths or any dependent API (Build, MustLoadContext, ...)\nif fs.ProjectRoot == \"\" {\n\treturn fmt.Errorf(\"no project root detected — run from inside a project directory or initialize the root first\")\n}","typeGuard":"func hasProjectRoot() bool {\n\treturn fs.ProjectRoot != \"\"\n}","tryCatchPattern":"paths, err := fs.GetProjectPaths(baseDir)\nif err != nil {\n\tif err.Error() == \"no project root found\" {\n\t\t// recover: run project discovery or prompt the user\n\t\troot, rerr := promptOrDetectRoot()\n\t\tif rerr != nil { return rerr }\n\t\tfs.ProjectRoot = root\n\t\tpaths, err = fs.GetProjectPaths(baseDir)\n\t}\n\tif err != nil { return err }\n}","preventionTips":["Always run the CLI from a directory containing the project marker files","If embedding the library, initialize ProjectRoot (via root detection) before any path-resolution call","Check that earlier startup/initialization steps succeeded before dependent commands","Validate the working directory in scripts before invoking project-scoped commands"],"tags":["go","cli","filesystem","initialization"],"backgroundTag":"missing-project-root","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}