Repository navigation
Preserve unresolved variables in process task command path (fixes #160891) - #316369
Merged
Megan Rogge (meganrogge) merged 2 commits intoNov 4, 2026
Conversation
When a `process`-type task uses a variable that is only known to the
main thread (for example `${command:python.interpreterPath}`), the
variable cannot be expanded by either:
- the extension host's variable resolver in `extHostTask.$resolveVariables`,
which has no command/input value mapping, or
- `_resolveAndFindExecutable` in `terminalTaskSystem`, which calls
`IConfigurationResolverService.resolveAsync` without an interaction
step.
Both code paths nevertheless treated the literal placeholder as a path,
fed it to `findExecutable`, and finally fell back to
`path.join(cwd, command)` when no executable was found. The resulting
string was a concatenation of the cwd and the unresolved placeholder
(for example `C:\\projects\\foo\\${command:python.interpreterPath}`).
A later resolution step then expanded the placeholder *inside* that
concatenation, producing a corrupted path such as
`C:\\projects\\foo\\C:\\Python310\\python.exe` and the user-facing
error:
```
The terminal process failed to launch: Path to shell executable
"C:\\projects\\foo\\C:\\Python310\\python.exe" does not exist.
```
Fix it by detecting an unresolved `${...}` placeholder after the local
resolve attempt and returning the value as-is. The task system already
runs another resolve pass over the resulting `__process__` variable
when constructing the shell launch config, which has access to the
fully resolved command/input values and produces the correct
executable path.
The change is symmetrical in the two places that share the
"resolve, find executable, otherwise prefix with cwd" pattern. No
behavior changes for command names that fully resolve in the local
scope.
Fixes microsoft#160891
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents process-type task command variables from being prematurely treated as executable paths, preserving unresolved ${...} placeholders so the later task variable resolution pass can substitute command/input values correctly.
Changes:
- Skips executable lookup/cwd-prefixing in the extension host when a resolved process name still contains a placeholder.
- Applies the same guard in the terminal task system’s Windows process executable resolution path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/vs/workbench/api/node/extHostTask.ts |
Preserves unresolved process command placeholders instead of passing them through executable lookup. |
src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts |
Avoids corrupting unresolved process task command placeholders before later task resolution. |
Megan Rogge (meganrogge)
approved these changes
Nov 3, 2026
Megan Rogge (meganrogge)
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the fix!
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Windows process-task resolution can launch the default shell for empty commands or resolve the wrong executable due to cwd/PATH handling, and regression tests covering the final executable are missing.
4 open issues
Review effort: Max
Comment on lines
+702
to
+703
| if (/\$\{.+?\}/.test(command)) { | ||
| return command; |
Comment on lines
+702
to
+703
| if (/\$\{.+?\}/.test(command)) { | ||
| return command; |
Comment on lines
+702
to
+703
| if (/\$\{.+?\}/.test(command)) { | ||
| return command; |
Comment on lines
+185
to
186
| if (/\$\{.+?\}/.test(processName)) { | ||
| result.process = processName; |
TylerLeonhardt
approved these changes
Nov 3, 2026
Raymond Zhao (rzhao271)
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Problem
A
process-type task that uses a command-backed variable produces a corrupted executable path on Windows:{ "version": "2.0.0", "tasks": [{ "label": "python: run", "type": "process", "command": "${command:python.interpreterPath}" }] }Running it currently fails with:
The original report (#160891) already pinpointed the location:
findExecutableis fed the literal${command:python.interpreterPath}and falls back topath.join(cwd, command). The resulting concatenation later has the placeholder expanded inside it and the workspace path is left in front of the real interpreter path.Root cause
Two code paths share the same "resolve, then
findExecutable, otherwise prefix with cwd" logic and both run before the command/input variables can be expanded:extHostTask.$resolveVariables(extension host, Node)_resolveAndFindExecutableinterminalTaskSystem.ts(main thread on Windows)Neither of these resolvers can expand
${command:...}or${input:...}on its own — those variables require an interaction step that runs later in the pipeline. After that interaction step the task system performs a second pass over the__process__variable when assembling the shell launch config (_createShellLaunchConfigcalls_resolveVariabletwice). It is at that point that command/input values are known and the path can be substituted correctly.The fix is to recognize when the local resolve step left a
${...}placeholder behind and return the value as-is, instead of pushing it throughfindExecutableand the cwd-prefix fallback. The downstream resolve pass then produces the correct path.Fix
src/vs/workbench/api/node/extHostTask.ts—$resolveVariables:resolver.resolveAsyncruns overprocess.name, check for a remaining${...}placeholder and, if found, return the unmodifiedprocessNameso the task system can resolve it later.src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts—_resolveAndFindExecutable:IConfigurationResolverService.resolveAsync, the same placeholder check; return the value directly when unresolved variables remain.Both changes are guarded by
/\$\{.+?\}/.test(...)so behavior is unchanged for any command name that fully resolves in the local scope.Why not resolve the command earlier?
Resolving
${command:...}happens on the main thread viaIConfigurationResolverService.resolveWithInteraction. The extension host has no command service, and_resolveAndFindExecutableruns before that interaction. Reordering would need the wider pipeline rework discussed in the issue. The minimal, targeted fix here lets the existing later resolve step do its job by simply not corrupting the value first.Testing
${...}remains the original branches (findExecutable→path.isAbsolute→path.join(cwd, ...)) are taken unchanged.Fixes #160891