Skip to content

Commit 66145b8

Browse files
committed
Update docker lookup path
1 parent e29c570 commit 66145b8

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

internal/server/server.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,13 @@ func (s *Server) handleAppClose() {
247247
}
248248

249249
func (s *Server) lookupContainerCommand() string {
250-
if _, err := exec.LookPath(PODMAN_COMMAND); err == nil {
251-
return PODMAN_COMMAND
252-
} else if _, err := exec.LookPath(DOCKER_COMMAND); err == nil {
253-
return DOCKER_COMMAND
250+
podmanExec := system.FindExec(PODMAN_COMMAND)
251+
if podmanExec != "" {
252+
return podmanExec
253+
}
254+
dockerExec := system.FindExec(DOCKER_COMMAND)
255+
if dockerExec != "" {
256+
return dockerExec
254257
}
255258
return ""
256259
}
@@ -437,15 +440,7 @@ func (s *Server) setupHTTPSServer() (*http.Server, error) {
437440
var mkcertPath string
438441
if s.config.Https.MkcertPath != "disable" {
439442
if s.config.Https.MkcertPath == "" {
440-
var err error
441-
mkcertPath, err = exec.LookPath("mkcert")
442-
if err != nil {
443-
if system.FileExists("/opt/homebrew/bin/mkcert") {
444-
mkcertPath = "/opt/homebrew/bin/mkcert"
445-
} else if system.FileExists("/usr/local/bin/mkcert") {
446-
mkcertPath = "/usr/local/bin/mkcert"
447-
}
448-
}
443+
mkcertPath = system.FindExec("mkcert")
449444
} else {
450445
mkcertPath = s.config.Https.MkcertPath
451446
}

internal/system/properties.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"context"
99
"fmt"
1010
"os"
11+
"os/exec"
12+
"path/filepath"
1113
"strings"
1214
)
1315

@@ -78,3 +80,27 @@ func FileExists(filename string) bool {
7880
_, err := os.Stat(filename)
7981
return err == nil // any error is treated as not exists
8082
}
83+
84+
// FindExec looks for the executable in the system PATH and returns its full path.
85+
// If not found, it checks common Homebrew locations for the executable.
86+
func FindExec(name string) string {
87+
path, err := exec.LookPath(name)
88+
if err == nil {
89+
return path
90+
}
91+
92+
// Homebrew services do not have the path set, lookup common paths
93+
paths := []string{
94+
"/usr/local/bin",
95+
"/opt/homebrew/bin",
96+
"/home/linuxbrew/.linuxbrew",
97+
}
98+
99+
for _, p := range paths {
100+
fullPath := filepath.Join(p, name)
101+
if FileExists(fullPath) {
102+
return fullPath
103+
}
104+
}
105+
return ""
106+
}

0 commit comments

Comments
 (0)