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

FIXES #201 Sail browser extension docker not found error on MacOS #264

Merged
merged 3 commits into from
Mar 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions globalflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package main

import (
"flag"
"fmt"
"net/url"
"os"
"os/exec"
"os/user"
"path/filepath"
"runtime"
"strings"

"github.com/fatih/color"
Expand Down Expand Up @@ -37,6 +39,16 @@ 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"
if !strings.Contains(path, localBin) {
sep := fmt.Sprintf("%c", os.PathListSeparator)
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)
Expand Down