Skip to content

Fix extension installation on running Windows servers - #328660

Open
arloor wants to merge 2 commits into
microsoft:mainfrom
arloor:agent/fix-windows-running-server-extension-install
Open

arloor wants to merge 2 commits into
microsoft:mainfrom
arloor:agent/fix-windows-running-server-extension-install

Conversation

@arloor

@arloor arloor commented Aug 3, 2026

Copy link
Copy Markdown

Summary

  • run extension installation for an already-running server through the platform-aware script launcher
  • pass extension flags as individual arguments instead of building a shell command string
  • cover Windows and non-Windows command construction with a unit test

Root cause

do_extension_install_on_running_server always invoked bash -c, including when the remote host was Windows. On the affected Windows host, bash resolved to the WindowsApps alias and failed with OS error 1920. A Git Bash installation would also interpret backslashes in the Windows command path as escapes.

This path is used when reconnecting to an existing server, which explains why the first connection succeeds and the second connection fails.

The fix reuses new_script_command, which invokes cmd /Q /C <script> on Windows and executes the script directly on other platforms.

Fixes microsoft/vscode-remote-release#11403

Validation

  • cargo test — 64 tests passed
  • cargo clippy -- -D warnings
  • rustfmt --edition 2021 --check src/tunnels/code_server.rs
  • reproduced the failure on the affected Windows host with bash -c
  • verified the equivalent cmd /Q /C code-server.cmd --version and --list-extensions --show-versions commands exit successfully on that host

Copilot AI review requested due to automatic review settings August 3, 2026 04:04

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.

🟡 Not ready to approve

The doc comment above the new builder function now mis-describes it while the consumer function lost its documentation; the fix is otherwise correct and well-tested.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR fixes extension installation when the CLI reconnects to an already-running server on Windows. Previously do_extension_install_on_running_server always invoked bash -c, which fails on Windows hosts (resolving to the WindowsApps bash alias / OS error 1920, or mangling backslashes under Git Bash). The fix routes the install through the existing platform-aware new_script_command helper (which runs cmd /Q /C <script> on Windows and the script directly elsewhere) and passes extension flags as separate arguments instead of a shell string.

Changes:

  • Extract new_extension_install_command, which builds the install command via new_script_command and appends --install-extension=<id> args individually.
  • Replace the bash -c invocation with .output() on the new command, mapping IO errors to CodeError::CommandFailed; drop the now-unused capture_command import.
  • Add a unit test asserting the constructed program/args differ correctly on Windows vs. non-Windows.
File summaries
File Description
cli/src/tunnels/code_server.rs Adds a platform-aware command builder for extension installation, switches the running-server install path away from bash -c, drops the unused import, and adds a cross-platform unit test.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread cli/src/tunnels/code_server.rs Resolved
Comment thread cli/src/tunnels/code_server.rs Resolved
@arloor

arloor commented Aug 3, 2026 via email

Copy link
Copy Markdown
Author

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot re-connect to windows host

2 participants