{"record":{"id":"851c82ed99127c4c","repo":"multica-ai/multica","slug":"execenv-remove-existing-env-w","errorCode":null,"errorMessage":"execenv: remove existing env: %w","messagePattern":"execenv: remove existing env: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/daemon/execenv/execenv.go","lineNumber":353,"sourceCode":"\t\treturn nil, fmt.Errorf(\"execenv: task ID is required\")\n\t}\n\n\tenvRoot := filepath.Join(params.WorkspacesRoot, params.WorkspaceID, shortID(params.TaskID))\n\n\t// Self-heal the root-level daemon marker on every task start so a marker\n\t// removed while the daemon runs is restored before the agent spawns. The\n\t// per-workdir marker written below only covers cwds inside the workdir;\n\t// the root marker keeps the CLI fail-closed guard active for subprocesses\n\t// that lose all MULTICA_* env vars AND escape above the workdir. Non-fatal:\n\t// without it the workdir marker still protects the common case.\n\tif err := EnsureWorkspacesRootMarker(params.WorkspacesRoot); err != nil && logger != nil {\n\t\tlogger.Warn(\"execenv: workspaces root marker not written; fail-closed guard limited to the task workdir\", \"error\", err)\n\t}\n\n\t// Remove existing env if present (defensive — task IDs are unique).\n\tif _, err := os.Stat(envRoot); err == nil {\n\t\tif err := os.RemoveAll(envRoot); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"execenv: remove existing env: %w\", err)\n\t\t}\n\t}\n\n\t// Create directory tree. For the standard flow the agent's workdir is\n\t// envRoot/workdir; for local_directory tasks the user's path takes its\n\t// place and we only need to create the scratch directories under\n\t// envRoot.\n\tworkDir := filepath.Join(envRoot, \"workdir\")\n\tscratchDirs := []string{filepath.Join(envRoot, \"output\"), filepath.Join(envRoot, \"logs\")}\n\tif params.LocalWorkDir == \"\" && params.LocalWorktree == nil {\n\t\tscratchDirs = append(scratchDirs, workDir)\n\t} else if params.LocalWorkDir != \"\" {\n\t\tworkDir = params.LocalWorkDir\n\t}\n\tfor _, dir := range scratchDirs {\n\t\tif err := os.MkdirAll(dir, 0o755); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"execenv: create directory %s: %w\", dir, err)\n\t\t}","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/execenv/execenv.go#L335-L371","documentation":"Error \"execenv: remove existing env: %w\" thrown in multica-ai/multica.","triggerScenarios":"Thrown at server/internal/daemon/execenv/execenv.go:353 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check permissions to remove the existing environment; remove it manually if needed."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}