#detect #run-time #windows

wsl

Detect if the program is running under Windows Subsystem for Linux

1 unstable release

0.1.0 Jun 12, 2019

#517 in Windows APIs

Download history 4315/week @ 2025-12-21 3920/week @ 2025-12-28 8372/week @ 2026-01-04 8989/week @ 2026-01-11 8529/week @ 2026-01-18 11085/week @ 2026-01-25 10634/week @ 2026-02-01 10647/week @ 2026-02-08 12591/week @ 2026-02-15 13560/week @ 2026-02-22 14358/week @ 2026-03-01 20055/week @ 2026-03-08 15248/week @ 2026-03-15 16194/week @ 2026-03-22 16138/week @ 2026-03-29 17065/week @ 2026-04-05

66,188 downloads per month
Used in 14 crates (9 directly)

MIT license

3KB

Detect if the program is running under Windows Subsystem for Linux

Usage

wsl::is_wsl()

Detect if the code is ran under Windows Subsystem for Linux

Usage

wsl::is_wsl() returns true under WSL, false otherwise.

Method

A semi-official source lists some pointers. We are going to use the simplest approach here: Testing if /proc/sys/kernel/osrelease contains string Microsoft or WSL.

No runtime deps