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) {
					continue

View on GitHub (pinned to e2d772072e)

Solutions

  1. Run `git ls-files` manually in the project directory to see the underlying git error, then fix it.
  2. Install/repair git and ensure it is on PATH in the execution environment.
  3. Add `git config --global --add safe.directory <repo-path>` for ownership mismatches.
  4. 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

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


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/fd78147d82f54201. Report an issue: GitHub.