{"record":{"id":"15a742145d902832","repo":"zed-industries/zed","slug":"could-not-resolve-task-variables-within-a-debug-sc","errorCode":null,"errorMessage":"Could not resolve task variables within a debug scenario","messagePattern":"Could not resolve task variables within a debug scenario","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/debugger_ui/src/session/running.rs","lineNumber":1143,"sourceCode":"                        let task = task_store.update(cx, |this, cx| {\n                            this.task_inventory().map(|inventory| {\n                                inventory.read(cx).task_template_by_label(\n                                    buffer,\n                                    worktree_id,\n                                    label,\n                                    cx,\n                                )\n                            })\n                        })?;\n                        let task = match task {\n                            Some(task) => task.await,\n                            None => None,\n                        }.with_context(|| format!(\"Couldn't find task template for {build:?}\"))?;\n                        (task, None)\n                    }\n                };\n                let Some(mut task) = task_template.resolve_task(\"debug-build-task\", &task_context) else {\n                    anyhow::bail!(\"Could not resolve task variables within a debug scenario\");\n                };\n\n                let locator_name = if let Some(locator_name) = locator_name {\n                    extra_config = config.clone();\n                    debug_assert!(!config_is_valid);\n                    Some(locator_name)\n                } else if !config_is_valid {\n                    let task = dap_store\n                        .update(cx, |this, cx| {\n                            this.debug_scenario_for_build_task(\n                                task.original_task().clone(),\n                                adapter.clone().into(),\n                                task.display_label().to_owned().into(),\n                                cx,\n                            )\n\n                        });\n                    if let Ok(t) = task {","sourceCodeStart":1125,"sourceCodeEnd":1161,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/debugger_ui/src/session/running.rs#L1125-L1161","documentation":"A debug scenario's `build` entry is resolved from a task template: `task_template.resolve_task(\"debug-build-task\", &task_context)` substitutes template variables against the task context; if any variable cannot be resolved it returns None and the debug session aborts with this error (running.rs:1143). The error is about variable substitution inside the build task, not about the debug config itself.","triggerScenarios":"A build task template referencing variables the debug task context does not provide — file-relative variables when no file context exists, custom/user variables, or a variable name that is not defined; also when the resolved context (worktree, active item) differs from what the template assumes.","commonSituations":"Running a debug scenario from a context with no open file; templates copied from tasks.json that use program-specific variables; variable renames after a Zed update; multi-worktree setups where the template assumes the wrong worktree root.","solutions":["Open the referenced build task template and replace unsupported variables with concrete values or supported ones ($ZED_WORKTREE_ROOT, $ZED_FILE, $ZED_ROW).","Run the same task standalone (task runner) to see which variable fails to substitute — the task UI shows the unresolved template.","Start the debug session from a context that provides the needed values (open the target file in the right worktree) before invoking the scenario."],"exampleFix":"// before (build task template — unresolvable in debug context)\n[\n  { \"label\": \"build\", \"command\": \"make build TARGET=$MY_CUSTOM_VAR\", \"use_new_terminal\": true }\n]\n\n// after\n[\n  { \"label\": \"build\", \"command\": \"make build\", \"cwd\": \"$ZED_WORKTREE_ROOT\", \"use_new_terminal\": true }\n]","handlingStrategy":"validation","validationCode":"// dry-run variable resolution before launching the debug session\nlet resolved = task_template.resolve_task(\"debug-build-task\", &task_context);\nif resolved.is_none() {\n    return Err(anyhow!(\"build task template has variables the current context cannot resolve\"));\n}","typeGuard":null,"tryCatchPattern":"On failure, fall back to showing the raw template with unresolvable variables highlighted (run the same task standalone in the task runner) instead of a bare bail.","preventionTips":["Prefer context-stable variables ($ZED_WORKTREE_ROOT) over file-dependent ones in build templates.","Test debug scenarios from the same context users will launch them from.","Keep a minimal template that resolves everywhere as the fallback build command."],"tags":["debugger","tasks","variables","zed"],"backgroundTag":"unresolved-template-variable","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}