Skip to content

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

@A13501350

Description

@A13501350

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}`);
        }
    }
    // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions