Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Commit 4ac2968

Browse files
authored
Merge pull request #264 from dougnukem/doug/chrome-extension/201
FIXES #201 Sail browser extension docker not found error on MacOS
2 parents 26ce409 + a063831 commit 4ac2968

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

globalflags.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package main
22

33
import (
44
"flag"
5+
"fmt"
56
"net/url"
67
"os"
78
"os/exec"
89
"os/user"
910
"path/filepath"
11+
"runtime"
1012
"strings"
1113

1214
"github.com/fatih/color"
@@ -37,6 +39,16 @@ func (gf *globalFlags) config() config {
3739

3840
// ensureDockerDaemon verifies that Docker is running.
3941
func (gf *globalFlags) ensureDockerDaemon() {
42+
// docker is installed in /usr/local/bin on MacOS, but this isn't in
43+
// $PATH when launched by a browser that was opened via Finder.
44+
if runtime.GOOS == "darwin" {
45+
path := os.Getenv("PATH")
46+
localBin := "/usr/local/bin"
47+
if !strings.Contains(path, localBin) {
48+
sep := fmt.Sprintf("%c", os.PathListSeparator)
49+
os.Setenv("PATH", strings.Join([]string{path, localBin}, sep))
50+
}
51+
}
4052
out, err := exec.Command("docker", "info").CombinedOutput()
4153
if err != nil {
4254
flog.Fatal("failed to run `docker info`: %v\n%s", err, out)

0 commit comments

Comments
 (0)