open-remote-ssh icon indicating copy to clipboard operation
open-remote-ssh copied to clipboard

[Bug] Platform Detection Fails for Windows Remote Hosts with Non-English CMD default Environments

Open A13501350 opened this issue 3 months ago • 0 comments

Open Remote - SSH extension relies on checking English error messages in "stderr" to identify Windows remote hosts when no manual "remote.SSH.remotePlatform" configuration is set. PowerShell default environments typically output English error keywords regardless of the system language, so this approach should generally work.

When the extension fails to match translated error messages, it may incorrectly treat the host as a Unix-like system (e.g., attempting to use bash), leading to installation failures.

[Trace  - 14:15:32.483] Server install command stdout:
[Error  - 14:15:32.484] Error resolving authority
Error: Failed parsing install script output

Even when the platform is manually specified as Windows, connection issues may persist because the extension cannot distinguish between PowerShell and Command Prompt. So when cmd is the default shell, it attempts to run PowerShell (pwsh) and fails:

{
  "remote.SSH.remotePlatform": {
    "windows-host-name": "windows"
  }
}

Current Logic

// serverSetup.ts
async function detectPlatform(conn: SSHConnection): Promise<string> {
    // ...
    // detect platform and shell for windows
    if (!platform || platform === 'windows') {
        const result = await conn.exec('uname -s');

        if (result.stdout) {
            if (result.stdout.includes('windows32')) {
                platform = 'windows';
            } else if (result.stdout.includes('MINGW64')) {
                platform = 'windows';
                shell = 'bash';
            }
        // Check for Windows via English error messages
        } else if (result.stderr) {
            if (result.stderr.includes('FullyQualifiedErrorId : CommandNotFoundException')) {
                platform = 'windows';
            }

            if (result.stderr.includes('is not recognized as an internal or external command')) {
                platform = 'windows';
                shell = 'cmd';
            }
        }

        if (platform) {
            logger.trace(`Detected platform: ${platform}, ${shell}`);
        }
    }
    // ...
}

A13501350 avatar Oct 05 '25 15:10 A13501350