diff --git a/base/path.jl b/base/path.jl
index 69c8d22c63c54..5d941db9075d6 100644
--- a/base/path.jl
+++ b/base/path.jl
@@ -655,7 +655,7 @@ function uripath end
else
function uripath(path::String)
localpath = join(eachsplit(abspath(path), path_separator_re, keepempty=false), '/')
- host = if ispath("/proc/sys/fs/binfmt_misc/WSLInterop") # WSL sigil
+ host = if Sys.isWSL()
distro = get(ENV, "WSL_DISTRO_NAME", "") # See
"wsl\$/$distro" # See and
else
diff --git a/base/sysinfo.jl b/base/sysinfo.jl
index 7dab313cf4f57..8a6bb772e41b0 100644
--- a/base/sysinfo.jl
+++ b/base/sysinfo.jl
@@ -80,7 +80,6 @@ A symbol representing the architecture of the build configuration.
"""
const ARCH = ccall(:jl_get_ARCH, Any, ())::Symbol
-
"""
Sys.KERNEL::Symbol
@@ -513,6 +512,19 @@ See documentation in [Handling Operating System Variation](@ref).
"""
iswindows(os::Symbol) = (os === :Windows || os === :NT)
+"""
+ Sys.isWSL([os])
+
+Predicate for testing if the OS is the Windows subsystem for Linux (version 2 or the original),
+running under a derivative of Microsoft Windows NT.
+See documentation in [Handling Operating System Variation](@ref).
+
+!!! compat "Julia 1.12"
+ This function requires at least Julia 1.12.
+"""
+# https://superuser.com/questions/1749781/how-can-i-check-if-the-environment-is-wsl-from-a-shell-script
+isWSL(os::Symbol) = ispath("/proc/sys/fs/binfmt_misc/WSLInterop") # WSL sigil
+
"""
Sys.isapple([os])