plandex-ai/plandex · error

error removing index.lock file: %v after %d attempts

Error message

error removing index.lock file: %v after %d attempts

What it means

removeLockFile exhausted its 10 attempts (with backoff) trying to delete a lingering git index.lock that still exists. The lock is being held/recreated by a concurrent git process, or deletion keeps failing (permissions).

Source

Thrown at app/server/db/git.go:568

			history = append(history, [2]string{sha, fullEntry})
		}
	}

	return history
}

func removeLockFile(lockFilePath string) error {
	_, err := os.Stat(lockFilePath)
	exists := err == nil
	// log.Println("index.lock file exists:", exists)
	if err != nil && !os.IsNotExist(err) {
		return fmt.Errorf("error checking lock file: %v", err)
	}

	attempts := 0
	for exists {
		if attempts > 10 {
			return fmt.Errorf("error removing index.lock file: %v after %d attempts", err, attempts)
		}

		log.Printf("[Git] removeLockFile - removing index.lock file: %s, attempt: %d", lockFilePath, attempts)

		if err := os.Remove(lockFilePath); err != nil {
			if os.IsNotExist(err) {
				log.Printf("[Git] removeLockFile - %s file not found, skipping removal", lockFilePath)
				return nil
			}

			return fmt.Errorf("error removing lock file: %v", err)
		}

		_, err = os.Stat(lockFilePath)
		exists = err == nil

		if err != nil && !os.IsNotExist(err) {
			return fmt.Errorf("error checking lock file: %v", err)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check no other git process is running against the repo
  2. Inspect permissions on the index.lock file
  3. Manually remove the stale lock if no git process holds it, then retry
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at app/server/db/git.go:568 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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