multica-ai/multica · error

create temp config file: %w

Error message

create temp config file: %w

What it means

The atomic-write sequence creates a temp file (.config-*.json.tmp) in the config directory before renaming it over the final path; os.CreateTemp failed. This is almost always a permission or disk-space error on the just-created directory, since the directory was verified moments earlier.

Source

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

			}
			if current == root {
				break
			}
			parent := filepath.Dir(current)
			if parent == current {
				return fmt.Errorf("task-local CLI config directory %q escapes root %q", dir, root)
			}
		}
	}
	data, err := json.MarshalIndent(cfg, "", "  ")
	if err != nil {
		return fmt.Errorf("encode CLI config: %w", err)
	}

	// 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)

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Check free space on the filesystem holding the config path (df)
  2. Verify write permission on the directory from the wrapped error path
  3. Clear immutable attributes (chattr -i) or security-software locks if present
  4. If using a /tmp-backed task root, move MULTICA_TASK_CONFIG_ROOT to persistent storage

Example fix

# before
$ multica config set ...
create temp config file: open /home/user/.multica/.config-123.json.tmp: no space left on device

# after
$ df -h /home  # free space, then retry
$ multica config set ...
Defensive patterns

Strategy: retry

Validate before calling

var stat syscall.Statfs_t
if err := syscall.Statfs(dir, &stat); err == nil && stat.Bavail == 0 {
	// no free space; alert before attempting the save
}

Try / catch

if err := cli.SaveCLIConfig(cfg); err != nil && errors.Is(err, syscall.ENOSPC) {
	// surface a disk-space alert; config file is untouched thanks to atomic write
}

Prevention

When it happens

Trigger: Calling SaveCLIConfig when the config directory becomes unwritable between MkdirAll and CreateTemp (racing chmod by the task-local walk, wrong ownership), when the disk is full, or when the filesystem disallows the O_EXCL create pattern.

Common situations: Disk full on the home partition; a security tool or immutable attribute blocking file creation; the directory being on a full tmpfs when MULTICA_TASK_CONFIG_ROOT points into /tmp.

Related errors


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