From 68495ea0ee0ef26863f661cbe8c1f124e7ef1efd Mon Sep 17 00:00:00 2001 From: aritmos <52433836+aritmos@users.noreply.github.com> Date: Fri, 22 Mar 2024 11:56:06 +0100 Subject: [PATCH] Fix container detection Running WSL without a container would be treated as native linux, causing problems at it would then attempt to use `xdg-open`. This was caused by `isContainer()` always returning true due to some dubious conditionals. These have been removed. The env-var check seems to not be used by lazygit, nor any common containers, and therefore appears to only exist to manually tell lazygit to behave as if it were inside of a container. This functionality has been kept, but the env-var has been changed to be all uppercaps as to comply with the POSIX standard. Fixes #2757 Bug introduced in 4d78d76 --- pkg/config/config_linux.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pkg/config/config_linux.go b/pkg/config/config_linux.go index 892e58de3ff..8aaea4576db 100644 --- a/pkg/config/config_linux.go +++ b/pkg/config/config_linux.go @@ -12,16 +12,9 @@ func isWSL() bool { func isContainer() bool { data, err := os.ReadFile("/proc/1/cgroup") - - if strings.Contains(string(data), "docker") || + return err == nil && (strings.Contains(string(data), "docker") || strings.Contains(string(data), "/lxc/") || - []string{string(data)}[0] != "systemd" && - []string{string(data)}[0] != "init" || - os.Getenv("container") != "" { - return err == nil && true - } - - return err == nil && false + os.Getenv("CONTAINER") != "") } // GetPlatformDefaultConfig gets the defaults for the platform