Skip to content

Commit

Permalink
Fix container detection (#3412)
Browse files Browse the repository at this point in the history
- **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
  • Loading branch information
stefanhaller committed Mar 22, 2024
2 parents 53363b7 + 68495ea commit 3675570
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions pkg/config/config_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3675570

Please sign in to comment.