{"record":{"id":"b9dbc689a074bf3c","repo":"plandex-ai/plandex","slug":"error-getting-git-root-s","errorCode":null,"errorMessage":"error getting git root: %s","messagePattern":"error getting git root: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/fs/paths.go","lineNumber":55,"sourceCode":"\tgitIgnoredDirs := map[string]bool{}\n\n\tisGitRepo := IsGitRepo(baseDir)\n\n\terrCh := make(chan error)\n\tvar mu sync.Mutex\n\tnumRoutines := 0\n\n\tdeletedFiles := map[string]bool{}\n\n\tif isGitRepo {\n\n\t\t// Use git status to find deleted files\n\t\tnumRoutines++\n\t\tgo func() {\n\t\t\tcmd := exec.Command(\"git\", \"rev-parse\", \"--show-toplevel\")\n\t\t\toutput, err := cmd.Output()\n\t\t\tif err != nil {\n\t\t\t\terrCh <- fmt.Errorf(\"error getting git root: %s\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\trepoRoot := strings.TrimSpace(string(output))\n\n\t\t\tcmd = exec.Command(\"git\", \"status\", \"--porcelain\")\n\t\t\tcmd.Dir = baseDir\n\t\t\tout, err := cmd.Output()\n\t\t\tif err != nil {\n\t\t\t\terrCh <- fmt.Errorf(\"error getting git status: %s\", err)\n\t\t\t}\n\n\t\t\tlines := strings.Split(string(out), \"\\n\")\n\n\t\t\tfor _, line := range lines {\n\t\t\t\tline = strings.TrimSpace(line)\n\t\t\t\tif strings.HasPrefix(line, \"D \") {\n\t\t\t\t\tpath := strings.TrimSpace(line[2:])\n\t\t\t\t\tabsPath := filepath.Join(repoRoot, path)","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/fs/paths.go#L37-L73","documentation":"GetPaths runs `git rev-parse --show-toplevel` in a background goroutine to locate the repository root so it can resolve deleted-file paths from `git status`. This error is thrown when that git command fails to execute or exits non-zero, meaning the code could not determine the repo root even though IsGitRepo(baseDir) returned true moments earlier. It is sent over errCh and returned from GetPaths, aborting the whole path scan.","triggerScenarios":"Calling GetPaths/GetProjectPaths on a directory that passed the IsGitRepo check but where `git rev-parse --show-toplevel` fails: e.g. the .git directory is corrupt or was deleted between the check and the call, git is not on PATH, or the git binary itself errors (e.g. dubious ownership detected by newer git versions).","commonSituations":"Running the CLI in a container or CI image where git is not installed or is a stripped-down binary; a repo owned by another user triggering git's 'detected dubious ownership' safe.directory error; a race where the repo was deleted/re-initialized mid-run; a corrupted .git directory.","solutions":["Verify `git rev-parse --show-toplevel` succeeds manually in baseDir; fix the repo (e.g. run `git config --global --add safe.directory <path>` if git reports dubious ownership).","Ensure git is installed and on PATH in the environment where the CLI runs.","Re-clone or repair a corrupt .git directory (e.g. `git init` again or restore from a clean copy).","If the directory is genuinely not a git repo, run the tool from a valid repository so IsGitRepo and the git commands agree."],"exampleFix":"// before (shell)\n$ plandex load\nerror getting git root: fatal: detected dubious ownership in repository at '/repo'\n// after (shell)\n$ git config --global --add safe.directory /repo\n$ plandex load","handlingStrategy":"validation","validationCode":"out, err := exec.Command(\"git\", \"-C\", baseDir, \"rev-parse\", \"--show-toplevel\").Output()\nif err != nil {\n\treturn fmt.Errorf(\"cannot resolve git root for %s: %w\", baseDir, err)\n}","typeGuard":null,"tryCatchPattern":"if err := <-errCh; err != nil {\n\tif strings.Contains(err.Error(), \"error getting git root\") {\n\t\t// fall back to non-git path scanning or prompt user to fix repo\n\t}\n}","preventionTips":["Verify `git rev-parse --show-toplevel` works in the target directory before invoking the tool","Install git in containers/CI images that run the CLI","Configure git safe.directory when running as a different user than the repo owner","Avoid deleting or re-initializing the repository while the tool is running"],"tags":["git","go","exec","filesystem"],"backgroundTag":"git-command-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}