Skip to content

Fix Copilot terminal profile resolution when shell doesn't exist - #321154

Merged
Megan Rogge (meganrogge) merged 3 commits into
mainfrom
meganrogge/fix-shell-resolution
Jun 12, 2026
Merged

Megan Rogge (meganrogge) merged 3 commits into
mainfrom
meganrogge/fix-shell-resolution

Conversation

@meganrogge

Copy link
Copy Markdown
Collaborator

Problem

When the resolved default shell (e.g. zsh) is not installed on the system, the Copilot terminal tool fails with Path to shell executable "zsh" does not exist. This causes all terminal commands to fail, including sandbox retries with network access.

Root Cause

TerminalProfileService.getDefaultProfile(os) filters out auto-detected profiles (!e.isAutoDetected). On Linux, the user-configured default (e.g. "bash") is typically auto-detected, so the lookup returns undefined. The fallback resolution can then pick up a shell that isn't actually installed (e.g. zsh from a stale profile list).

Fix

Added a validation step in getCopilotProfile() that checks whether the resolved shell binary exists on disk (via IFileService.exists). When it doesn't, it falls back to the first available shell from [/bin/bash, /usr/bin/bash, /bin/sh].

Only applies to non-Windows platforms since Windows shell paths are handled differently.

Fixes #319302

When the resolved default shell (e.g. zsh) is not installed on the
system, the Copilot terminal tool fails with 'Path to shell executable
does not exist'. This adds a validation step in getCopilotProfile that
checks whether the resolved shell binary exists on disk and falls back
to /bin/bash or /bin/sh when it doesn't.

Fixes #319302

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 12, 2026 14:05
@vs-code-engineering

vs-code-engineering Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Anthony Kim (@anthonykim1)

Matched files:

  • src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the Copilot “Run in Terminal” tool’s robustness when resolving the terminal profile by validating that the resolved shell executable exists and falling back to a known POSIX shell when it doesn’t, avoiding failures like Path to shell executable "zsh" does not exist.

Changes:

  • Add POSIX shell fallback candidates and validation for non-Windows shell executables.
  • Introduce filesystem existence checks via IFileService.exists and emit a warning when falling back.
Show a summary per file
File Description
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts Adds shell existence validation and POSIX fallback selection for Copilot’s terminal profile resolution.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 3

@meganrogge
Megan Rogge (meganrogge) merged commit c1d6f5b into main Jun 12, 2026
25 checks passed
@meganrogge
Megan Rogge (meganrogge) deleted the meganrogge/fix-shell-resolution branch June 12, 2026 15:27
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jul 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command still doesn't run after approving unrestricted network access in the sandbox

3 participants