#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

#750 in Operating systems

Download history 7630/week @ 2024-10-14 7028/week @ 2024-10-21 7840/week @ 2024-10-28 8179/week @ 2024-11-04 8050/week @ 2024-11-11 8324/week @ 2024-11-18 7059/week @ 2024-11-25 9103/week @ 2024-12-02 9689/week @ 2024-12-09 7936/week @ 2024-12-16 2009/week @ 2024-12-23 2866/week @ 2024-12-30 7447/week @ 2025-01-06 7356/week @ 2025-01-13 7624/week @ 2025-01-20 7334/week @ 2025-01-27

30,066 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