File tree Expand file tree Collapse file tree 2 files changed +34
-13
lines changed Expand file tree Collapse file tree 2 files changed +34
-13
lines changed Original file line number Diff line number Diff line change @@ -247,10 +247,13 @@ func (s *Server) handleAppClose() {
247
247
}
248
248
249
249
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
254
257
}
255
258
return ""
256
259
}
@@ -437,15 +440,7 @@ func (s *Server) setupHTTPSServer() (*http.Server, error) {
437
440
var mkcertPath string
438
441
if s .config .Https .MkcertPath != "disable" {
439
442
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" )
449
444
} else {
450
445
mkcertPath = s .config .Https .MkcertPath
451
446
}
Original file line number Diff line number Diff line change 8
8
"context"
9
9
"fmt"
10
10
"os"
11
+ "os/exec"
12
+ "path/filepath"
11
13
"strings"
12
14
)
13
15
@@ -78,3 +80,27 @@ func FileExists(filename string) bool {
78
80
_ , err := os .Stat (filename )
79
81
return err == nil // any error is treated as not exists
80
82
}
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
+ }
You can’t perform that action at this time.
0 commit comments