Skip to content

Commit 524f492

Browse files
committed
feat(wsl): detect wsl
1 parent cc6b87a commit 524f492

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/PkgAuthentication.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import Pkg
66
import Random
77
import TOML
88

9+
include("helpers.jl")
10+
911
const pkg_server_env_var_name = "JULIA_PKG_SERVER"
1012

1113
## abstract state types
@@ -520,8 +522,8 @@ function open_browser(url::AbstractString)
520522
@debug "error executing browser hook" exception=(err, catch_backtrace())
521523
return false
522524
end
523-
elseif Sys.iswindows()
524-
run(`cmd /c "start $url"`; wait=false)
525+
elseif Sys.iswindows() || detectwsl()
526+
run(`cmd.exe /c "start $url"`; wait=false)
525527
elseif Sys.isapple()
526528
run(`open $url`; wait=false)
527529
elseif Sys.islinux() || Sys.isbsd()

src/helpers.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Vendored from Pluto.jl#src/notebook/path helpers.jl
2+
# from https://github.com/JuliaLang/julia/pull/36425
3+
function detectwsl()
4+
Sys.islinux() &&
5+
isfile("/proc/sys/kernel/osrelease") &&
6+
occursin(r"Microsoft|WSL"i, read("/proc/sys/kernel/osrelease", String))
7+
end

0 commit comments

Comments
 (0)