Skip to content

Commit 3675570

Browse files
authored
Fix container detection (#3412)
- **PR Description** 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
2 parents 53363b7 + 68495ea commit 3675570

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

pkg/config/config_linux.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,9 @@ func isWSL() bool {
1212

1313
func isContainer() bool {
1414
data, err := os.ReadFile("/proc/1/cgroup")
15-
16-
if strings.Contains(string(data), "docker") ||
15+
return err == nil && (strings.Contains(string(data), "docker") ||
1716
strings.Contains(string(data), "/lxc/") ||
18-
[]string{string(data)}[0] != "systemd" &&
19-
[]string{string(data)}[0] != "init" ||
20-
os.Getenv("container") != "" {
21-
return err == nil && true
22-
}
23-
24-
return err == nil && false
17+
os.Getenv("CONTAINER") != "")
2518
}
2619

2720
// GetPlatformDefaultConfig gets the defaults for the platform

0 commit comments

Comments
 (0)