multica-ai/multica · error

stat %s copy %s: %w

Error message

stat %s copy %s: %w

What it means

materialiseInCodexHome Lstats the destination relPath to decide whether a stale-copy removal is needed. Any error other than not-exist is surfaced here — e.g. permission denied on a parent directory, or I/O failure — because the copy cannot proceed safely without knowing the destination state.

Source

Thrown at server/internal/daemon/execenv/codex_home.go:1027

// identity-checked by openVerifiedCodexHomeRoot.
func materialiseInCodexHome(codexHome, relPath, src, key string) error {
	root, err := openVerifiedCodexHomeRoot(codexHome, key)
	if err != nil {
		return err
	}
	defer root.Close()

	if dir := filepath.Dir(relPath); dir != "." {
		if err := root.MkdirAll(dir, 0o755); err != nil {
			return fmt.Errorf("create %s directory %s: %w", key, dir, err)
		}
	}
	if _, err := root.Lstat(relPath); err == nil {
		if err := root.Remove(relPath); err != nil {
			return fmt.Errorf("remove stale %s copy %s: %w", key, relPath, err)
		}
	} else if !os.IsNotExist(err) {
		return fmt.Errorf("stat %s copy %s: %w", key, relPath, err)
	}

	in, err := os.Open(src)
	if err != nil {
		return fmt.Errorf("open %s %s: %w", key, src, err)
	}
	defer in.Close()

	out, err := root.OpenFile(relPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644)
	if err != nil {
		return fmt.Errorf("create %s copy %s: %w", key, relPath, err)
	}
	defer out.Close()

	if _, err := io.Copy(out, in); err != nil {
		return fmt.Errorf("copy %s %s to %s: %w", key, src, relPath, err)
	}
	// Close explicitly so a deferred write-back failure cannot be swallowed; the

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Fix permissions on the intermediate directories under the task home
  2. Recreate the task home
  3. Check volume/filesystem health if I/O errors appear in daemon logs
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Lstat(filepath.Join(codexHome, relPath)); err != nil && !errors.Is(err, fs.ErrNotExist) {
	return fmt.Errorf("destination path unprobeable: %w", err)
}

Prevention

When it happens

Trigger: A parent of relPath denies search permission; filesystem I/O error during Lstat; dangling path components with wrong types.

Common situations: Task home with user-mangled permissions from a prior task; failing disk or volume.

Related errors


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