multica-ai/multica · error

rename config file: %w

Error message

rename config file: %w

What it means

The final atomic step — os.Rename of the temp file over config.json — failed. Common errnos: EXDEV cannot happen (same directory), so in practice this is EACCES/EPERM from directory permissions or a stale handle on Windows systems where the destination is open in another process.

Source

Thrown at server/internal/cli/config.go:374

		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

  1. Fix write permission/ownership on the directory containing config.json
  2. Close any editors or processes holding the config file open and retry (Windows)
  3. If config.json somehow became a directory, remove it and retry the save
  4. Retry once — the temp file from the failed attempt is already cleaned up
Defensive patterns

Strategy: try-catch

Try / catch

if err := cli.SaveCLIConfig(cfg); err != nil && strings.Contains(err.Error(), "rename config file") {
	// check directory writability and (on Windows) open handles, then retry
}

Prevention

When it happens

Trigger: SaveCLIConfig when the config directory is not writable by the current user at rename time, or (on Windows) when another process holds config.json open, or when the destination is a directory.

Common situations: Ownership changed by an earlier sudo run; an editor or the daemon holding the config file open on Windows; MULTICA_TASK_CONFIG_ROOT directories chmod'd by a different task walk.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/0f817d3e3729758f. Report an issue: GitHub.