doctor: detect wsl 1 and wsl 2 separately (#7081)

pull/7094/head
Swastik Baranwal 2020-12-02 19:11:13 +05:30 committed by GitHub
parent 2691163a7e
commit 1356ac63b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 4 deletions

View File

@ -50,18 +50,26 @@ fn (mut a App) collect_info() {
}
//
mut os_details := ''
wsl_check := a.cmd({
command: 'cat /proc/sys/kernel/osrelease'
})
if os_kind == 'linux' {
os_details = a.get_linux_os_name()
info := a.cpu_info()
if 'hypervisor' in info['flags'] {
if 'microsoft' in a.cmd({
command: 'cat /proc/sys/kernel/osrelease'
}) {
os_details += ' (WSL)'
if 'microsoft' in wsl_check {
// WSL 2 is a Managed VM and Full Linux Kernel
// See https://docs.microsoft.com/en-us/windows/wsl/compare-versions
os_details += ' (WSL 2)'
} else {
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
if a.cmd(command: '[ "$(awk \'\$5=="/" {print \$1}\' </proc/1/mountinfo)" != "$(awk \'\$5=="/" {print \$1}\' </proc/$$/mountinfo)" ] ; echo \$?') == '0' {
os_details += ' (chroot)'