plandex-ai/plandex · error
failed to stat map file %s: %v
Error message
failed to stat map file %s: %v
What it means
Raised while refreshing map (repo-map) contexts: each mapped file is re-statted to detect changes, and an os.Stat error other than NotExist is surfaced here. NotExist is treated as 'removed', so this error means stat failed for a different reason (permissions, I/O, mount issues).
Source
Thrown at app/cli/lib/context_update.go:668
var removed bool
var hasFileInfo bool
mu.Lock()
if _, ok := mapFileInfoByPath[path]; ok {
hasFileInfo = true
} else if _, ok := mapFileRemovedByPath[path]; ok {
removed = true
}
mu.Unlock()
if !(hasFileInfo || removed) {
fileInfo, err := os.Stat(path)
if err != nil {
if os.IsNotExist(err) {
removed = true
} else {
innerExistenceErrCh <- fmt.Errorf("failed to stat map file %s: %v", path, err)
return
}
}
mu.Lock()
prevTokens := ctx.MapTokens[path]
prevSize := ctx.MapSizes[path]
if removed {
mapFileRemovedByPath[path] = true
totalMapPaths--
if _, existed := ctx.MapShas[path]; existed {
state.removedMapPaths = append(state.removedMapPaths, path)
tokenDiffsById[ctx.Id] -= prevTokens
state.totalMapSize -= prevSize
}
} else {
mapFileInfoByPath[path] = fileInfoView on GitHub (pinned to e2d772072e)
Solutions
- Check the wrapped %v cause and restore read access (chmod/chown) on the mapped file.
- If the file moved, remove and rebuild the map context so its file list matches disk.
- Re-run the refresh if the file was being modified concurrently by another tool.
- For network mounts, verify the mount is healthy before refreshing.
Example fix
// before -rw------- locked.go # stat/permission error in map refresh // after chmod 644 locked.go
Defensive patterns
Strategy: validation
Validate before calling
for _, p := range mappedFiles {
if _, err := os.Stat(p); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("mapped file %s not statable: %w", p, err)
}
} Try / catch
if err := refreshMapCtx(ctx); err != nil {
if strings.Contains(err.Error(), "failed to stat map file") {
// restore permissions or rebuild map
}
} Prevention
- Keep permissions stable on mapped files (644/755)
- Avoid file locks from antivirus/indexers on repo dirs
- Rebuild the map after large file moves
- Avoid network filesystems for repo maps
When it happens
Trigger: os.Stat(path) on a file recorded in ctx.MapTokens returns an error that is not os.IsNotExist, inside the per-map-file innerExistenceErrCh goroutine.
Common situations: File permissions tightened since the map was built; file replaced by a directory or vice versa mid-refresh; NFS/network filesystem returning EIO; antivirus locking the file on Windows.
Related errors
- failed to get file info for %s: %v
- failed to get map file details for %s: %v
- error loading accounts: %v
- error setting auth: %v
- error writing auth: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/3aaa8358afaca883.
Report an issue: GitHub.