#detection #run-time #detect #windows

wsl

Detect if the program is running under Windows Subsystem for Linux

1 unstable release

0.1.0 Jun 12, 2019

#726 in Operating systems

Download history 8205/week @ 2024-11-16 7275/week @ 2024-11-23 9212/week @ 2024-11-30 9081/week @ 2024-12-07 8665/week @ 2024-12-14 1911/week @ 2024-12-21 2774/week @ 2024-12-28 7321/week @ 2025-01-04 7450/week @ 2025-01-11 7721/week @ 2025-01-18 7382/week @ 2025-01-25 8100/week @ 2025-02-01 8203/week @ 2025-02-08 6208/week @ 2025-02-15 7604/week @ 2025-02-22 8243/week @ 2025-03-01

31,524 downloads per month
Used in 10 crates (7 directly)

MIT license

3KB

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.


lib.rs:

Detect if the program is running under Windows Subsystem for Linux

Usage

wsl::is_wsl()

No runtime deps