Skip to content

fix(wsl): decode UTF-16 version output - #12

Merged
cursor[bot] merged 3 commits into
mainfrom
cursor/wsl-utf16-version-989b
Oct 11, 2026
Merged

cursor[bot] merged 3 commits into
mainfrom
cursor/wsl-utf16-version-989b

Conversation

@timeroute

Copy link
Copy Markdown
Owner

Summary

First launch treated an installed WSL 3.0.1.0 as missing. wsl.exe --version writes UTF-16LE when stdout is a pipe. The setup probe read those bytes with String::from_utf8_lossy, so ASCII came through with NUL gaps (W\0S\0L\0 \03\0.\00\0.\01\0.\00) and 版本 showed up as Latin-1 Hr,g. The version scanner splits on anything that is not a digit or ., so 3.0.1.0 never formed a token and the check failed.

  • Capture stdout/stderr as bytes and decode UTF-16LE/BE when a BOM or a typical UTF-16LE NUL pattern is present. If that does not match, strip NULs that sit between ASCII bytes.
  • Parse the WSL product line (WSL version: / WSL 版本:), not the kernel, WSLg, or Windows lines. A spaced misread (W S L Hr,g: 3 . 0 . 1 . 0) still collapses back to 3.0.1.0.
  • 3.0.1.0 satisfies >= 2.9.3 (fourth component is the Windows revision; a missing component counts as 0). Older than 2.9.3 stops setup and asks for wsl --update.

Test plan

  • cargo test -- wslc::sdk_version (Linux): UTF-16LE Chinese wsl --version bytes, UTF-16LE BOM on stderr, NUL-separated misread, spaced Hr,g regression, odd-length NUL-strip fallback, kernel/WSLg lines ignored, 2.9.3 boundary and 3.0.1.0 >= 2.9.3
  • Windows: first launch with WSL 3.0.1.0 (Chinese locale) logs Host version: 3.0.1.0 instead of “could not read version”
Open in Web Open in Cursor 

`wsl --version` writes UTF-16LE when stdout is a pipe. Reading
those bytes as UTF-8 splits 3.0.1.0 with NUL gaps, so first
launch reports WSL as missing. Accept 3.0.1.0 as >= 2.9.3.

Co-authored-by: 绿岸公式 <chinesejar@gmail.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

cursoragent and others added 2 commits October 11, 2026 09:44
Keep the first-launch WSL gate from main and decode
`wsl --version` as UTF-16LE so 3.0.1.0 still passes >= 2.9.3.

Co-authored-by: 绿岸公式 <chinesejar@gmail.com>
Record the UTF-16 WSL version fix under 0.1.2.

Co-authored-by: 绿岸公式 <chinesejar@gmail.com>
@cursor
cursor Bot merged commit 76ed4bc into main Oct 11, 2026
1 check failed
@timeroute
timeroute deleted the cursor/wsl-utf16-version-989b branch October 11, 2026 10:18
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.

2 participants