plandex-ai/plandex · error
error getting files in git repo: %s
Error message
error getting files in git repo: %s
What it means
The tracked-files goroutine runs `git ls-files` with cmd.Dir set to baseDir to enumerate all files git tracks. This error is thrown when that command exits non-zero or cannot be executed, so GetPaths aborts and returns the error instead of a ProjectPaths struct.
Source
Thrown at app/cli/fs/paths.go:97
deletedFiles[relPath] = true
}
}
errCh <- nil
}()
// combine `git ls-files` and `git ls-files --others --exclude-standard`
// to get all files in the repo
numRoutines++
go func() {
// get all tracked files in the repo
cmd := exec.Command("git", "ls-files")
cmd.Dir = baseDir
out, err := cmd.Output()
if err != nil {
errCh <- fmt.Errorf("error getting files in git repo: %s", err)
return
}
files := strings.Split(string(out), "\n")
mu.Lock()
defer mu.Unlock()
for _, file := range files {
absFile := filepath.Join(baseDir, file)
relFile, err := filepath.Rel(currentDir, absFile)
if err != nil {
errCh <- fmt.Errorf("error getting relative path: %s", err)
return
}
if ignored != nil && ignored.MatchesPath(relFile) {
continueView on GitHub (pinned to e2d772072e)
Solutions
- Run `git ls-files` manually in the project directory to see the underlying git error, then fix it.
- Install/repair git and ensure it is on PATH in the execution environment.
- Add `git config --global --add safe.directory <repo-path>` for ownership mismatches.
- Remove a stale .git/index.lock (with no git process running) or restore a corrupt index (`git read-tree HEAD` / re-clone).
Example fix
// before (Dockerfile) FROM alpine CMD ["plandex", "load"] // after FROM alpine RUN apk add --no-cache git CMD ["plandex", "load"]
Defensive patterns
Strategy: validation
Validate before calling
if out, err := exec.Command("git", "-C", baseDir, "ls-files").Output(); err != nil {
return fmt.Errorf("git ls-files failed in %s: %s", baseDir, err)
} Try / catch
if err := <-errCh; err != nil {
if strings.Contains(err.Error(), "error getting files in git repo") {
// fall back to filepath.Walk-based scanning or surface the wrapped git error
}
} Prevention
- Ensure git is installed and on PATH in every environment that runs the tool
- Check repo health with `git fsck` if errors persist
- Configure safe.directory for ownership mismatches
- Do not delete the repository or its .git directory mid-operation
When it happens
Trigger: Calling GetPaths on a repo where `git ls-files` fails: corrupt or missing .git/index, dubious-ownership rejection, git not found on PATH, insufficient read permissions on the repo, or repo deleted between the IsGitRepo check and this call.
Common situations: Running in CI containers without git installed; repo mounted read-only or owned by another user; corrupt index after a crash (stale .git/index.lock); git safe.directory errors when the repo is owned by a different UID.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- error getting git root: %s
- error getting git status: %s
- error getting untracked files in git repo: %s
- error storing context: %v
- error removing lock file: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/fd78147d82f54201.
Report an issue: GitHub.