fix: detect WSL on non-English Windows locales - #85
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the WSL availability check on Windows by introducing a helper function isWslAvailable that runs wsl --status instead of parsing localized stdout strings. Feedback suggests improving this check by using wsl -l -q to ensure that at least one Linux distribution is actually installed and registered, preventing potential failures when executing commands via WSL.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 0 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull request overview
Fixes incorrect WSL detection on Windows systems using non-English locales by switching from parsing localized wsl --status output to using command success/failure as the signal for WSL availability. This ensures the MCP uses WinWSLCodacyCli only when WSL truly isn’t available, rather than failing due to locale-dependent labels.
Changes:
- Add
isWslAvailable()helper that treats a successfulwsl --statusexecution as proof WSL is available. - Replace string-based WSL detection (
stdout.includes('Default Distribution')) with the new helper.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
This PR successfully addresses WSL detection issues on non-English Windows locales by switching from output string parsing to checking command execution status. While Codacy indicates the code is up to standards, the transition to wsl --status introduces a potential functional gap: the command may return a successful exit code even if no WSL distributions are installed. This could result in the CLI incorrectly selecting the WSL-based implementation over the standard Windows implementation. Furthermore, there are no automated tests included to verify the new detection logic or the factory's fallback behavior, and the implementation lacks a timeout mechanism to handle cases where the WSL subsystem might hang.
About this PR
- The implementation relies on the exit code of
wsl --status. While this solves the localization issue, it removes the specific check for a 'Default Distribution' presence; ifwsl --statusreturns success without a distribution configured, it might lead to downstream failures inWinWSLCodacyCli. - The PR does not include automated tests (unit or integration) to verify the new detection logic or the factory selection logic.
Test suggestions
- isWslAvailable returns true when 'wsl --status' succeeds
- isWslAvailable returns false when 'wsl --status' fails or is not found
- Cli.createInstance selects WinWSLCodacyCli when WSL is detected
- Cli.createInstance selects WinCodacyCli when WSL detection fails
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. isWslAvailable returns true when 'wsl --status' succeeds
2. isWslAvailable returns false when 'wsl --status' fails or is not found
3. Cli.createInstance selects WinWSLCodacyCli when WSL is detected
4. Cli.createInstance selects WinCodacyCli when WSL detection fails
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
Hi! We are going to release a version soon where you no longer need to worry about WSL detection! Our new CLI makes everything easier :) |
Alrighty, then this can be ignored 🙏 |
Problem
On Windows, local Codacy CLI analysis via MCP fails with:
"CLI on Windows is not supported without WSL."
…even when WSL is installed and working.
Root cause: WSL detection parses
wsl --statusoutput for the English string"Default Distribution". On localized Windows installs the label differs, e.g.:Standard-Distribution: UbuntuDistribution par défaut: UbuntuVýchozí distribuce: DebianSo
hasWSLis alwaysfalseand the MCP usesWinCodacyCli, which rejects all operations.Fix
Treat a successful
wsl --statusexit as proof WSL is available, instead ofmatching a locale-specific label.
Alternative Fix
Alternative fix would be to use regex:
const hasWSL = /:\s*\S+/m.test(stdout); // "Something: Ubuntu"Test plan
codacy_cli_analyzeworkscodacy_cli_analyzeworks