multica-ai/multica · error
chmod temp config file: %w
Error message
chmod temp config file: %w
What it means
Before the final rename, the temp file is chmod'd to 0600 so the saved config is owner-only. That chmod failed — usually because the file was already gone (a concurrent cleaner) or because ownership changed mid-operation. The temp file is then removed and the save fails safely.
Source
Thrown at server/internal/cli/config.go:370
// Write to a temp file in the same directory, then rename for atomicity.
tmp, err := os.CreateTemp(dir, ".config-*.json.tmp")
if err != nil {
return fmt.Errorf("create temp config file: %w", err)
}
tmpPath := tmp.Name()
if _, err := tmp.Write(append(data, '\n')); err != nil {
tmp.Close()
os.Remove(tmpPath)
return fmt.Errorf("write temp config file: %w", err)
}
if err := tmp.Close(); err != nil {
os.Remove(tmpPath)
return fmt.Errorf("close temp config file: %w", err)
}
if err := os.Chmod(tmpPath, 0o600); err != nil {
os.Remove(tmpPath)
return fmt.Errorf("chmod temp config file: %w", err)
}
if err := os.Rename(tmpPath, path); err != nil {
os.Remove(tmpPath)
return fmt.Errorf("rename config file: %w", err)
}
return nil
}
View on GitHub (pinned to 2c0912b6ec)
Solutions
- Serialize config saves per profile (a lockfile or running one CLI at a time) to eliminate the race
- Exclude the config directory from temp-file cleaners
- Ensure only one user account writes to a given task-local root
- Simply retry the save — the next attempt will use a fresh temp file
Defensive patterns
Strategy: retry
Try / catch
if err := cli.SaveCLIConfig(cfg); err != nil && errors.Is(err, os.ErrNotExist) {
// temp file vanished (race with cleaner); retry the save
err = cli.SaveCLIConfig(cfg)
} Prevention
- Serialize concurrent config saves per profile (lockfile)
- Exclude .config-*.json.tmp patterns from temp cleaners
- Run only one user against each task-local root
When it happens
Trigger: A concurrent process (another CLI instance, a tmp cleaner, antivirus) deleting the temp file between creation and chmod; or ownership confusion when different users run the CLI against the same task-local root.
Common situations: Two CLI invocations racing to save the same profile; systemd-tmpfiles or a cron job cleaning dot-prefixed temp files; concurrent daemon and manual CLI writes to one MULTICA_TASK_CONFIG_ROOT.
Related errors
- mint PAT: response missing token
- daemon profile is not resolved yet; token sync skipped
- runtime local skill discovery timed out
- runtime local skill import failed
- resolve profile %q: %w
AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15).
Data as JSON: /api/errors/738b1bed6ce44539.
Report an issue: GitHub.