multica-ai/multica · error
rename temp to %s: %w
Error message
rename temp to %s: %w
What it means
writeFileAtomic wrote, chmod'd, and closed the temp file but os.Rename over the destination failed. The rename-in-same-directory design rules out EXDEV in normal operation, so this is usually a Windows sharing violation (another process holds the open destination) or a permission problem on replacing the destination entry.
Source
Thrown at server/internal/daemon/execenv/hermes_home.go:933
tmp, err := os.CreateTemp(dir, ".hermes-tmp-*")
if err != nil {
return fmt.Errorf("create temp for %s: %w", dst, err)
}
tmpName := tmp.Name()
defer os.Remove(tmpName) // no-op once renamed
if _, err := tmp.Write(data); err != nil {
tmp.Close()
return fmt.Errorf("write temp for %s: %w", dst, err)
}
if err := tmp.Chmod(perm); err != nil {
tmp.Close()
return fmt.Errorf("chmod temp for %s: %w", dst, err)
}
if err := tmp.Close(); err != nil {
return fmt.Errorf("close temp for %s: %w", dst, err)
}
if err := os.Rename(tmpName, dst); err != nil {
return fmt.Errorf("rename temp to %s: %w", dst, err)
}
return nil
}
View on GitHub (pinned to 2c0912b6ec)
Solutions
- Stop overlapping processes on the same env (one task per env RootDir; previous child fully exited) and retry.
- On Windows, exclude the env root from AV/indexing; retry after handles release.
- Check rename permission on the directory for the daemon UID and any MAC denials in audit logs.
- Delete the dst file manually if it is stuck; prepare recreates it atomically.
Defensive patterns
Strategy: retry
Try / catch
err := writeFileAtomic(dst, data, perm)
if err != nil {
var le syscall.Errno
if errors.As(err, &le) && le == syscall.Errno(32) { // EACCES/sharing-violation class on Windows
time.Sleep(200 * time.Millisecond)
err = writeFileAtomic(dst, data, perm) // holders often release quickly
}
}
return err Prevention
- Ensure the reader of a derived file (Hermes child) has exited before the next prepare replaces it.
- Exclude env roots from Windows AV/indexing to avoid rename sharing violations.
- One prepare at a time per env RootDir.
When it happens
Trigger: On Windows, a reader (Hermes child, AV, indexer) holds dst open at replace time; dst is a directory while the temp is a file; the dir was made read-only or foreign-owned between CreateTemp and Rename;SELinux/AppArmor denying rename.
Common situations: A task's Hermes process still reading config.yaml while the next prepare refreshes it; antivirus scanning freshly written temp files on Windows; containers with restrictive MAC policy on the env volume.
Related errors
- remove legacy task state %s: %w
- clear hermes skills dir: %w
- runtime local skill import timed out
- replace binary: %w
- mirror %s: %w
AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15).
Data as JSON: /api/errors/9e53d5613b88c670.
Report an issue: GitHub.