plandex-ai/plandex · error
failed to remove %s: %w
Error message
failed to remove %s: %w
What it means
During rewind apply, os.Remove fails on a file that must be deleted (its target content is empty) and the file does exist (IsNotExist is tolerated). Real removal failures are permissions, directories-as-files, or file locks.
Source
Thrown at app/cli/lib/rewind.go:277
if len(requiredChanges) == 0 {
return nil
}
// Track directories that might need cleanup
dirsToCheck := make(map[string]bool)
var mu sync.Mutex
errCh := make(chan error, len(requiredChanges))
for path, content := range requiredChanges {
go func(path, content string) {
dstPath := filepath.Join(fs.ProjectRoot, path)
if content == "" {
// Remove the file
err := os.Remove(dstPath)
if err != nil && !os.IsNotExist(err) {
errCh <- fmt.Errorf("failed to remove %s: %w", path, err)
return
}
// Mark parent directory for cleanup
parentDir := filepath.Dir(dstPath)
mu.Lock()
dirsToCheck[parentDir] = true
mu.Unlock()
errCh <- nil
return
}
// Ensure directory exists
if err := os.MkdirAll(filepath.Dir(dstPath), 0755); err != nil {
errCh <- fmt.Errorf("failed to create directory for %s: %w", path, err)
return
}
// Write the fileView on GitHub (pinned to e2d772072e)
Solutions
- Check the wrapped error for permission or EBUSY conditions
- Manually remove the file if it is locked by another process
- Re-run the rewind; already-removed files are skipped via IsNotExist tolerance
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at app/cli/lib/rewind.go:277 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/471cbc4002de60d8.
Report an issue: GitHub.