From 524f4923b4cf326606626e303d4231896b843629 Mon Sep 17 00:00:00 2001 From: Panagiotis Georgakopoulos Date: Wed, 29 Jan 2025 20:24:42 +0200 Subject: [PATCH 1/3] feat(wsl): detect wsl --- src/PkgAuthentication.jl | 6 ++++-- src/helpers.jl | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 src/helpers.jl diff --git a/src/PkgAuthentication.jl b/src/PkgAuthentication.jl index a5ff8bc..28850ae 100644 --- a/src/PkgAuthentication.jl +++ b/src/PkgAuthentication.jl @@ -6,6 +6,8 @@ import Pkg import Random import TOML +include("helpers.jl") + const pkg_server_env_var_name = "JULIA_PKG_SERVER" ## abstract state types @@ -520,8 +522,8 @@ function open_browser(url::AbstractString) @debug "error executing browser hook" exception=(err, catch_backtrace()) return false end - elseif Sys.iswindows() - run(`cmd /c "start $url"`; wait=false) + elseif Sys.iswindows() || detectwsl() + run(`cmd.exe /c "start $url"`; wait=false) elseif Sys.isapple() run(`open $url`; wait=false) elseif Sys.islinux() || Sys.isbsd() diff --git a/src/helpers.jl b/src/helpers.jl new file mode 100644 index 0000000..c80bd4f --- /dev/null +++ b/src/helpers.jl @@ -0,0 +1,7 @@ +# Vendored from Pluto.jl#src/notebook/path helpers.jl +# from https://github.com/JuliaLang/julia/pull/36425 +function detectwsl() + Sys.islinux() && + isfile("/proc/sys/kernel/osrelease") && + occursin(r"Microsoft|WSL"i, read("/proc/sys/kernel/osrelease", String)) +end From 05b5657ae2e0e396bc1f035b9fbc85d90e91fcb8 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Mon, 17 Feb 2025 14:58:25 +1300 Subject: [PATCH 2/3] borrow detectwsl implementation from Julia --- src/helpers.jl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/helpers.jl b/src/helpers.jl index c80bd4f..6a9eda9 100644 --- a/src/helpers.jl +++ b/src/helpers.jl @@ -1,7 +1,14 @@ -# Vendored from Pluto.jl#src/notebook/path helpers.jl -# from https://github.com/JuliaLang/julia/pull/36425 -function detectwsl() - Sys.islinux() && - isfile("/proc/sys/kernel/osrelease") && - occursin(r"Microsoft|WSL"i, read("/proc/sys/kernel/osrelease", String)) +@static if isdefined(Sys, :detectwsl) + const detectwsl = Sys.detectwsl +else + # Borrowed from Julia (MIT license) + # https://github.com/JuliaLang/julia/blob/726c816b9590d748345fb615b76b685c79eafd0d/base/sysinfo.jl#L549-L555 + # https://github.com/JuliaLang/julia/pull/57069 + function detectwsl() + # We use the same approach as canonical/snapd do to detect WSL + islinux() && ( + isfile("/proc/sys/fs/binfmt_misc/WSLInterop") + || isdir("/run/WSL") + ) + end end From 095de1d33c2f92fe86349fa79c5330e8cc46a5cb Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Mon, 17 Feb 2025 14:59:35 +1300 Subject: [PATCH 3/3] set version to 2.1.0 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 99d35a6..d9e3618 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PkgAuthentication" uuid = "4722fa14-9d28-45f9-a1e2-a38605bd88f0" authors = ["Sebastian Pfitzner", "contributors"] -version = "2.0.3" +version = "2.1.0" [deps] Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"