From 5bd868eeb1c78f291fdfb2f9077ad40cad284fa2 Mon Sep 17 00:00:00 2001 From: Douglas Daniels Date: Tue, 10 Mar 2020 17:55:55 -0500 Subject: [PATCH 1/3] FIXES #201 Sail browser extension docker not found error on MacOS --- globalflags.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/globalflags.go b/globalflags.go index 2f89ecb..c51cc9c 100644 --- a/globalflags.go +++ b/globalflags.go @@ -2,11 +2,13 @@ package main import ( "flag" + "fmt" "net/url" "os" "os/exec" "os/user" "path/filepath" + "runtime" "strings" "github.com/fatih/color" @@ -37,6 +39,15 @@ func (gf *globalFlags) config() config { // ensureDockerDaemon verifies that Docker is running. func (gf *globalFlags) ensureDockerDaemon() { + if runtime.GOOS == "darwin" { + path := os.Getenv("PATH") + localBin := "/usr/local/bin" + if !strings.Contains(path, localBin) { + sep := fmt.Sprintf("%c", os.PathListSeparator) + // Fix for MacOS to include /usr/local/bin where docker is commonly installed which is not included in $PATH when sail is launched by browser that was opened in Finder + os.Setenv("PATH", strings.Join([]string{path, localBin}, sep)) + } + } out, err := exec.Command("docker", "info").CombinedOutput() if err != nil { flog.Fatal("failed to run `docker info`: %v\n%s", err, out) From 8beac84c5e7fcd86118aef105ae154c8ea8a3c6d Mon Sep 17 00:00:00 2001 From: Doug Daniels Date: Tue, 17 Mar 2020 12:36:58 -0500 Subject: [PATCH 2/3] Update globalflags.go Co-Authored-By: Dean Sheather --- globalflags.go | 1 - 1 file changed, 1 deletion(-) diff --git a/globalflags.go b/globalflags.go index c51cc9c..d4fdd70 100644 --- a/globalflags.go +++ b/globalflags.go @@ -44,7 +44,6 @@ func (gf *globalFlags) ensureDockerDaemon() { localBin := "/usr/local/bin" if !strings.Contains(path, localBin) { sep := fmt.Sprintf("%c", os.PathListSeparator) - // Fix for MacOS to include /usr/local/bin where docker is commonly installed which is not included in $PATH when sail is launched by browser that was opened in Finder os.Setenv("PATH", strings.Join([]string{path, localBin}, sep)) } } From a0638312fae469dd99348ef793ac20f0218f119a Mon Sep 17 00:00:00 2001 From: Doug Daniels Date: Tue, 17 Mar 2020 12:37:10 -0500 Subject: [PATCH 3/3] Update globalflags.go Co-Authored-By: Dean Sheather --- globalflags.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/globalflags.go b/globalflags.go index d4fdd70..87b8a50 100644 --- a/globalflags.go +++ b/globalflags.go @@ -39,6 +39,8 @@ func (gf *globalFlags) config() config { // ensureDockerDaemon verifies that Docker is running. func (gf *globalFlags) ensureDockerDaemon() { + // docker is installed in /usr/local/bin on MacOS, but this isn't in + // $PATH when launched by a browser that was opened via Finder. if runtime.GOOS == "darwin" { path := os.Getenv("PATH") localBin := "/usr/local/bin"