doctor: detect wsl 1 and wsl 2 separately (#7081)
parent
2691163a7e
commit
1356ac63b4
|
@ -50,18 +50,26 @@ fn (mut a App) collect_info() {
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
mut os_details := ''
|
mut os_details := ''
|
||||||
|
wsl_check := a.cmd({
|
||||||
|
command: 'cat /proc/sys/kernel/osrelease'
|
||||||
|
})
|
||||||
if os_kind == 'linux' {
|
if os_kind == 'linux' {
|
||||||
os_details = a.get_linux_os_name()
|
os_details = a.get_linux_os_name()
|
||||||
info := a.cpu_info()
|
info := a.cpu_info()
|
||||||
if 'hypervisor' in info['flags'] {
|
if 'hypervisor' in info['flags'] {
|
||||||
if 'microsoft' in a.cmd({
|
if 'microsoft' in wsl_check {
|
||||||
command: 'cat /proc/sys/kernel/osrelease'
|
// WSL 2 is a Managed VM and Full Linux Kernel
|
||||||
}) {
|
// See https://docs.microsoft.com/en-us/windows/wsl/compare-versions
|
||||||
os_details += ' (WSL)'
|
os_details += ' (WSL 2)'
|
||||||
} else {
|
} else {
|
||||||
os_details += ' (VM)'
|
os_details += ' (VM)'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// WSL 1 is NOT a Managed VM and Full Linux Kernel
|
||||||
|
// See https://docs.microsoft.com/en-us/windows/wsl/compare-versions
|
||||||
|
if 'Microsoft' in wsl_check {
|
||||||
|
os_details += ' (WSL)'
|
||||||
|
}
|
||||||
// From https://unix.stackexchange.com/a/14346
|
// From https://unix.stackexchange.com/a/14346
|
||||||
if a.cmd(command: '[ "$(awk \'\$5=="/" {print \$1}\' </proc/1/mountinfo)" != "$(awk \'\$5=="/" {print \$1}\' </proc/$$/mountinfo)" ] ; echo \$?') == '0' {
|
if a.cmd(command: '[ "$(awk \'\$5=="/" {print \$1}\' </proc/1/mountinfo)" != "$(awk \'\$5=="/" {print \$1}\' </proc/$$/mountinfo)" ] ; echo \$?') == '0' {
|
||||||
os_details += ' (chroot)'
|
os_details += ' (chroot)'
|
||||||
|
|
Loading…
Reference in New Issue