From 9c719dc6202b4105699ff4727b7ded487b18a182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1ll=20Haraldsson?= Date: Sun, 24 Nov 2024 16:16:05 +0000 Subject: [PATCH 1/4] Introduce Sys.isWSL() --- base/path.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 2f976f3a5e9b5995ab368c1e20be1892f1775012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1ll=20Haraldsson?= Date: Sun, 24 Nov 2024 16:30:15 +0000 Subject: [PATCH 2/4] Update sysinfo.jl --- base/sysinfo.jl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 7dab313cf4f57..ccb1a2df4f247 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 +iswindows(os::Symbol) = ispath("/proc/sys/fs/binfmt_misc/WSLInterop") # WSL sigil + """ Sys.isapple([os]) From acc12947567e950a45cb3530f9bdd5cfaf97f1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1ll=20Haraldsson?= Date: Sun, 24 Nov 2024 17:32:26 +0000 Subject: [PATCH 3/4] Update sysinfo.jl --- base/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index ccb1a2df4f247..25c72577206a3 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -523,7 +523,7 @@ See documentation in [Handling Operating System Variation](@ref). 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 -iswindows(os::Symbol) = ispath("/proc/sys/fs/binfmt_misc/WSLInterop") # WSL sigil +isWSL(os::Symbol) = ispath("/proc/sys/fs/binfmt_misc/WSLInterop") # WSL sigil """ Sys.isapple([os]) From f988fd73fbd810a756160740eacd6c58091753b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1ll=20Haraldsson?= Date: Sun, 24 Nov 2024 17:33:17 +0000 Subject: [PATCH 4/4] Update sysinfo.jl --- base/sysinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 25c72577206a3..8a6bb772e41b0 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -522,7 +522,7 @@ 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 +# 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 """