mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
doctor: detect wsl 1 and wsl 2 separately (#7081)
This commit is contained in:
parent
2691163a7e
commit
1356ac63b4
@ -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)'
|
||||
|
Loading…
Reference in New Issue
Block a user