Skip to content

Conversation

@ThanhNguyxn
Copy link
Contributor

@ThanhNguyxn ThanhNguyxn commented Dec 10, 2025

Description

This PR fixes the port forwarding issue on Windows Insiders where the tunnel command fails with ENOENT error after updates.

The Problem

On Windows Insiders, the folder structure after updates is:

C:\...\Microsoft VS Code Insiders\
├── bin/                     # bin folder exists at root
│   └── code-tunnel-insiders.exe
├── <version>/               # version folder (e.g., da9c9d69cb)
│   ├── Code - Insiders.exe
│   └── resources/
│       └── app/             # ← vscode.env.appRoot points here
└── (other files...)

The current code uses ../../bin which resolves to <version>/bin (doesn't exist!).
The correct path should be ../../../bin to reach root/bin.

The Fix

Added platform-specific path resolution in extensions/tunnel-forwarding/src/extension.ts:

  • macOS: bin (directly under appRoot)
  • Windows Insiders: ../../../bin (3 levels up: resources/app → root/bin)
  • Other platforms: ../../bin (unchanged)

Path Analysis

From: resources/app (appRoot)
  ..           → resources
  ../..        → <version>
  ../../..     → root
  ../../../bin → root/bin ✓

Fixes #282425

Copilot AI review requested due to automatic review settings December 10, 2025 09:27
@vs-code-engineering
Copy link

vs-code-engineering bot commented Dec 10, 2025

📬 CODENOTIFY

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

@bpasero

Matched files:

  • src/vs/code/node/cli.ts

Copy link
Contributor

Copilot AI left a comment

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 fixes the tunnel command path resolution for Windows Insiders builds, addressing ENOENT errors that occur when port forwarding after updates.

Key Changes:

  • Added special case for Windows Insiders to navigate up two directory levels from process.execPath to find the bin/ folder at root level
  • Refactored the appPath logic to use explicit conditionals instead of a ternary operator for better clarity

Copy link
Collaborator

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR but I don't think the following code path is triggering the issue, both Code - Insiders.exe and bin are at the same root level.

@deepak1556
Copy link
Collaborator

The fix needs to happen here

: path.join(
vscode.env.appRoot,
process.platform === 'darwin' ? 'bin' : '../../bin',
vscode.env.appQuality === 'stable' ? 'code-tunnel' : 'code-tunnel-insiders',
) + (process.platform === 'win32' ? '.exe' : '');

@ThanhNguyxn ThanhNguyxn force-pushed the fix/port-forwarding-path-282425 branch from 3309280 to 3eb1d5e Compare December 10, 2025 12:50
@ThanhNguyxn
Copy link
Contributor Author

Thanks @deepak1556 for pointing out the correct location!

I've updated the PR to apply the fix in extensions/tunnel-forwarding/src/extension.ts instead of cli.ts. Changed the path from ../../bin to ../bin to correctly resolve the tunnel command path on Windows Insiders.

@ThanhNguyxn ThanhNguyxn force-pushed the fix/port-forwarding-path-282425 branch from 3eb1d5e to 10682b2 Compare December 10, 2025 12:57
On Windows Insiders, the bin folder is at root level while appRoot
points to resources/app inside the versioned folder. Changed path
resolution to use '../../../bin' (3 levels up) for Windows Insiders
specifically, while keeping '../../bin' for other platforms.

- macOS: 'bin' (directly under appRoot)
- Windows Insiders: '../../../bin' (resources/app -> root/bin)
- Other platforms: '../../bin'

Fixes microsoft#282425
@ThanhNguyxn ThanhNguyxn force-pushed the fix/port-forwarding-path-282425 branch from 10682b2 to 4a2f4b2 Compare December 10, 2025 13:03
@ThanhNguyxn
Copy link
Contributor Author

Updated the PR based on @deepak1556's feedback:

  1. Moved fix to the correct location (extensions/tunnel-forwarding/src/extension.ts)
  2. Corrected the path: Changed from ../../bin to ../../../bin for Windows Insiders

The key insight is that vscode.env.appRoot on Windows Insiders points to <root>/<version>/resources/app, so we need 3 levels up (../../../) to reach the root bin folder, not 2 levels.

Path analysis:

From: resources/app (appRoot)
  ../../bin     → <version>/bin  ❌ (doesn't exist)
  ../../../bin  → root/bin       ✅ (correct!)

@ThanhNguyxn
Copy link
Contributor Author

Apologies for the messy commit history earlier - I had some confusion about the correct path resolution. The PR should now be clean with just the single correct fix. Thanks for your patience! 🙏

Comment on lines +30 to +31
: process.platform === 'win32' && vscode.env.appQuality !== 'stable'
? '../../../bin' // Windows Insiders: resources/app -> root/bin
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
: process.platform === 'win32' && vscode.env.appQuality !== 'stable'
? '../../../bin' // Windows Insiders: resources/app -> root/bin
: process.platform === 'win32' && vscode.env.appQuality === 'insider'
? '../../../bin' // TODO: remove as part of https://github.com/microsoft/vscode/issues/282514

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.

[Insiders] Port forwarding fails after update due to missing bin folder in version directory

3 participants