Commit 323ca86
base: add
Close JuliaLang#36425, fix JuliaLang#36354
## How to detect WSL?
There are a number of ways that can be used to detect WSL environments,
but each can have false positives.
We finally chose to use the same method as Snapd to detect WSL.
Because Windows installs Ubuntu LTS as WSL by default.
So we assume that Snapd's detection method will work for most users.
- Ubuntu/Snapd:
https://github.com/canonical/snapd/blob/03a578a5dff26467dcc80580fcd4720a486185a5/release/release.go#L151-L172
- microsoft/WSL#423
- microsoft/WSL#4071
- https://superuser.com/q/1749781/1460597
## Known limitations
- this is a runtime test, and thus cannot meaningfully be used in
`@static if` constructs.
- Linux users can create their own
- `/proc/sys/fs/binfmt_misc/WSLInterop` file
- or `/run/WSL/` folder
to pretend to be a WSL environment.
---
- I've tested this under: Ubuntu 22.04.5 LTS (default/Offical) and
alpine-release-3.17.0 (win store)
- [x] Add compat, NEWS, tests
- [x] Take a look at different detect methods,
figure out which one is more robust
---------
Co-authored-by: Gautam Mishra <[email protected]>
Co-authored-by: Max Horn <[email protected]>
Co-authored-by: Chengyu Han <[email protected]>
Co-authored-by: Alex Arslan <[email protected]>Sys.detectwsl() (JuliaLang#57069)1 parent 4e13e0e commit 323ca86
4 files changed
+30
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
532 | 533 | | |
533 | 534 | | |
534 | 535 | | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
535 | 557 | | |
536 | 558 | | |
537 | 559 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | | - | |
| 317 | + | |
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| |||
0 commit comments