multica-ai/multica · error
remove stale memories path %s: %w
Error message
remove stale memories path %s: %w
What it means
Returned by mountHermesMemories when os.RemoveAll fails while deleting the overlay's task-local memories/ path after it was migrated (or found as a non-store symlink). The removal is the last step of repointing HERMES_HOME/memories at the agent-scoped persistent store, so failure means the mount cannot proceed and the task overlay build aborts.
Source
Thrown at server/internal/daemon/execenv/hermes_memory.go:168
if fi, err := os.Lstat(dst); err == nil {
if fi.Mode()&os.ModeSymlink != 0 {
if target, rlErr := os.Readlink(dst); rlErr == nil && filepath.Clean(target) == filepath.Clean(storeDir) {
if err := os.MkdirAll(storeDir, 0o700); err != nil {
return fmt.Errorf("create hermes memory store %s: %w", storeDir, err)
}
touchHermesMemoryStore(storeDir, logger)
return nil
}
} else if fi.IsDir() {
// Runs before the store dir is created, so migration can publish a
// fully-copied tree with one atomic rename. Fails closed: the source
// dir below is only removed once every entry is safely in the store.
if err := migrateHermesTaskMemories(dst, storeDir, logger); err != nil {
return err
}
}
if err := os.RemoveAll(dst); err != nil {
return fmt.Errorf("remove stale memories path %s: %w", dst, err)
}
} else if !os.IsNotExist(err) {
return fmt.Errorf("stat memories path %s: %w", dst, err)
}
if err := os.MkdirAll(storeDir, 0o700); err != nil {
return fmt.Errorf("create hermes memory store %s: %w", storeDir, err)
}
if err := createDirLink(storeDir, dst); err != nil {
return fmt.Errorf("link memories to store %s: %w", storeDir, err)
}
// Stamp the store as just-used: mounting it does not touch its mtime, so
// without this the GC's idle check could reclaim a long-idle agent's memory
// right as a task picks it back up.
touchHermesMemoryStore(storeDir, logger)
return nil
}
View on GitHub (pinned to 2c0912b6ec)
Solutions
- Check the wrapped error: EACCES/EPERM means permissions (chown or delete the stale dir manually), EBUSY/sharing-violation means a process holds it open (stop other tasks/daemons, retry).
- Manually move the stale <task-home>/memories aside and re-run; the store migration already copied its contents, so nothing is lost.
- Ensure only one daemon instance per Multica profile dir runs concurrently.
Example fix
// before: stale dir blocks mount, task overlay fails % ls ~/.multica/…/hermes/memories # owned by another user // after: remove the stale path as the daemon user, then re-run % sudo rm -rf ~/.multica/…/hermes/memories % multica daemon restart
Defensive patterns
Strategy: retry
Validate before calling
// Before mounting, confirm the daemon can remove the stale path:
if fi, err := os.Lstat(dst); err == nil && fi.IsDir() {
if err := os.RemoveAll(dst); err != nil {
log.Printf("pre-check failed, fix before task start: %v", err)
}
} Try / catch
// In the caller of mountHermesMemories:
if err := mountHermesMemories(home, store, logger); err != nil {
if strings.Contains(err.Error(), "remove stale memories path") && isTransientFS(err) {
// single retry after brief backoff; EBUSY/AV locks often clear
time.Sleep(500 * time.Millisecond)
err = mountHermesMemories(home, store, logger)
}
if err != nil { return fmt.Errorf("overlay mount: %w", err) }
} Prevention
- Run only one daemon per Multica profile dir
- Keep daemon and task overlays under the same OS user
- Exclude the profile dir from antivirus on-access scanning
When it happens
Trigger: os.RemoveAll(dst) on <overlay-hermes-home>/memories fails: a file inside is held open with mandatory locking semantics, the directory or one of its children has read-only/0700-not-owner permissions, an antivirus or indexer on Windows holds a handle, or another concurrent task is writing into the same task-local memories dir mid-delete.
Common situations: Upgrading a daemon on a machine where a legacy real memories/ directory exists; running the daemon under a service account that lacks ownership of files written by an earlier user-run daemon; two tasks sharing one task dir racing on the same memories path.
Related errors
- read hermes memory store %s: %w
- read task-local hermes memories %s: %w
- create hermes memory store parent %s: %w
- mint PAT: response missing token
- daemon profile is not resolved yet; token sync skipped
AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15).
Data as JSON: /api/errors/d7cdddda0701cda5.
Report an issue: GitHub.