Skip to content

WSL Detection Fails on Non-English Windows Systems #165

@peschull

Description

@peschull

Bug Report: WSL Detection Fails on Non-English Windows Systems

Summary

The Codacy VS Code extension fails to detect WSL on non-English Windows systems because it checks for the English string "Default Distribution" in wsl --status output, which is localized.

Environment

  • OS: Windows 11 (German locale: de-DE)
  • VS Code Version: 1.96+
  • Codacy Extension Version: 1.11.7
  • WSL Version: 2
  • WSL Distribution: Ubuntu (Running, Default)

Steps to Reproduce

  1. Install Windows with a non-English locale (e.g., German)
  2. Install WSL 2 with Ubuntu as default distribution
  3. Install Codacy VS Code extension
  4. Extension fails to detect WSL, MCP server doesn't start automatically

Expected Behavior

The extension should detect WSL regardless of Windows display language.

Actual Behavior

WSL detection fails because wsl --status returns localized output.

English Windows Output:

Default Distribution: Ubuntu
Version: 2

German Windows Output:

Standarddistribution: Ubuntu
Version: 2

Root Cause

In src/cli/index.ts, the detection logic uses:

stdout.includes('Default Distribution')

This only works on English Windows systems.

Suggested Fix

Use a locale-independent detection method:

Option 1: Use wsl -l -q (quiet mode, no localized text)

const { stdout } = await execAsync('wsl -l -q');
const hasDistributions = stdout.trim().length > 0;

Option 2: Check multiple locale strings

const wslIndicators = [
  'Default Distribution',  // English
  'Standarddistribution',  // German
  'Distribution par défaut', // French
  'Distribución predeterminada', // Spanish
  // ... other locales
];
const hasWsl = wslIndicators.some(indicator => stdout.includes(indicator));

Option 3: Use registry or PowerShell (most reliable)

// Check if any WSL distribution exists
const { stdout } = await execAsync('wsl --list --quiet 2>nul');
const hasWsl = stdout.trim().split('\n').filter(Boolean).length > 0;

Workaround

Users can manually configure the MCP server in VS Code settings:

{
  "mcp.servers": {
    "codacy": {
      "type": "stdio",
      "command": "wsl",
      "args": ["-d", "Ubuntu", "--", "npx", "-y", "@codacy/codacy-mcp"]
    }
  }
}

Impact

  • All non-English Windows users with WSL cannot use the automatic WSL detection
  • Affects German, French, Spanish, Portuguese, Chinese, Japanese, and many other locales
  • Users must manually configure MCP server or use native Windows installation

Additional Context

Tested and confirmed working with manual configuration:

  • Node.js 20.19.6 in WSL Ubuntu
  • npx -y @codacy/codacy-mcp starts successfully
  • MCP server responds correctly: "Codacy MCP Server running on stdio"

Submitted by: Peter Schuller
Date: 2025-12-02

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions