Check if the process is running inside Windows Subsystem for Linux (Bash on Windows)
by sindresorhusJavaScript
Last 12 weeks · 3 commits
4 of 6 standards met
The fundamental check in this package is effectively equivalent . But you can run custom Linux kernels with arbitrary version strings inside WSL2, so this check is fragile and unreliable. There's no 100% reliable solution that I'm aware of, but there's some additional indicators that strongly point to a Linux environment being WSL2: The environment variable is set. VS Code's launcher script uses this, though obviously programs may be running with sanitized environment variables so an absence of this doesn't guarantee that we're not WSL. The existence of some mountpoints and paths that are distro-independent. If any of these exist, we're probably in WSL (and probably not in a container)
Repository: sindresorhus/is-wsl. Description: Check if the process is running inside Windows Subsystem for Linux (Bash on Windows) Stars: 199, Forks: 10. Primary language: JavaScript. Languages: JavaScript (98.1%), TypeScript (1.9%). License: MIT. Latest release: v3.1.1 (2w ago). Open PRs: 0, open issues: 0. Last activity: 2w ago. Community health: 85%. Top contributors: sindresorhus, coreyfarrell, BendingBender, KyivJunta, PVermeer, mwcoomber, justjavac.
Currently there is no way to to disable , which leads to undesired effects with tools consuming . As an example the Web Test Runner will try to use the Chrome binary from Windows, even when Chrome is installed in WSL. This PR introduces usage of the environment variable to disable the functionality. This allows consumers of downstream tools to prevent undesired calls to Windows binaries as an opt-in.