multica-ai/multica · error

could not remove the runtime's own files from the worktree b

Error message

could not remove the runtime's own files from the worktree before committing: %w

What it means

Error "could not remove the runtime's own files from the worktree before committing: %w" thrown in multica-ai/multica.

Source

Thrown at server/internal/daemon/daemon.go:6628

			// every other file Prepare placed under WorkDir. Together
			// they round-trip the workdir to its exact pre-task bytes.
			if cerr := execenv.CleanupSidecars(env.RootDir); cerr != nil {
				if cleanupErr == nil {
					cleanupErr = cerr
				}
				d.logger.Warn("execenv: cleanup sidecars failed", "error", cerr)
			}
			// In worktree mode a failed cleanup is NOT survivable: Finalize is
			// about to `git add -A`, so whatever the cleanup could not remove
			// gets committed and delivered as the task's branch — a diff whose
			// content is Multica's own runtime files, which is precisely what
			// this mode promises never to produce. Tell Finalize to abort
			// instead, so nothing is committed and the worktree is kept for
			// inspection. (In place there is no commit and no branch, so a
			// cleanup failure stays a warning: the leftover files are visible
			// in the user's own tree and removable by hand.)
			if cleanupErr != nil && env.LocalWorktree != nil {
				env.LocalWorktree.AbortWithReason(fmt.Errorf(
					"could not remove the runtime's own files from the worktree before committing: %w", cleanupErr))
			}
		}()
	}
	taskTempDir, err := ensureTaskTempDir(env.RootDir, task.WorkspaceID, task.ID)
	if err != nil {
		return TaskResult{}, fmt.Errorf("prepare task temp dir: %w", err)
	}
	defer func() {
		if cerr := os.RemoveAll(taskTempDir); cerr != nil {
			taskLog.Warn("task temp dir cleanup failed", "path", taskTempDir, "error", cerr)
		}
	}()

	// Issue #3999 race A: now that env.WorkDir is on disk, transition the
	// server-side state machine dispatched (or waiting_local_directory) →
	// running. Calling StartTask before Prepare/Reuse let any consumer
	// that read status==running and resolved

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Check worktree permissions; remove the runtime files manually if needed.

When it happens

Trigger: Thrown at server/internal/daemon/daemon.go:6628 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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