sipeed/picoclaw · error
failed to write temp file
Error message
failed to write temp file: %w
What it means
WriteFileAtomic's write to the temp file failed (disk full, I/O error). The original file is untouched; the deferred cleanup closes and removes the temp file so no partial data is ever renamed into place.
Solutions
- Free disk space and verify the filesystem is writable
- Retry the write; the original file was not modified
- Check storage device health (especially flash media on edge devices)
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at pkg/fileutil/file.go:82 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15).
Data as JSON: /api/errors/bbbfacbe2be2953e.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/fileutil/file.go:82
)
if err != nil {
return fmt.Errorf("failed to create temp file: %w", err)
}
tmpPath := tmpFile.Name()
cleanup := true
defer func() {
if cleanup {
tmpFile.Close()
_ = os.Remove(tmpPath)
}
}()
// Write data to temp file
// Note: Original file is untouched at this point
if _, err := tmpFile.Write(data); err != nil {
return fmt.Errorf("failed to write temp file: %w", err)
}
// CRITICAL: Force sync to storage medium before any other operations.
// This ensures data is physically written to disk, not just cached.
// Essential for SD cards, eMMC, and other flash storage on edge devices.
if err := tmpFile.Sync(); err != nil {
return fmt.Errorf("failed to sync temp file: %w", err)
}
// Set file permissions before closing
if err := tmpFile.Chmod(perm); err != nil {
return fmt.Errorf("failed to set permissions: %w", err)
}
// Close file before rename (required on Windows)
if err := tmpFile.Close(); err != nil {
return fmt.Errorf("failed to close temp file: %w", err)
}View on GitHub (pinned to 49183d7e8d)