github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/docker/docker_darwin.go (about)

     1  package docker
     2  
     3  import (
     4  	"os/exec"
     5  
     6  	"github.com/mutagen-io/mutagen/pkg/platform"
     7  )
     8  
     9  // commandSearchPaths specifies locations on macOS where we might find the
    10  // docker binary.
    11  var commandSearchPaths = []string{
    12  	"/usr/local/bin",
    13  }
    14  
    15  // commandPathForPlatform will search for a suitable docker command
    16  // implementation on macOS.
    17  func commandPathForPlatform() (string, error) {
    18  	// First, attempt to find the docker executable using the PATH environment
    19  	// variable. If that works, use that result.
    20  	if path, err := exec.LookPath("docker"); err == nil {
    21  		return path, nil
    22  	}
    23  
    24  	// If the PATH-based lookup fails, attempt to search a set of common
    25  	// locations where Docker installations reside on macOS. This is
    26  	// unfortunately necessary due to launchd stripping almost everything out of
    27  	// the PATH environment variable, including /usr/local/bin, the default
    28  	// installation path for Docker for Mac. This fallback is only necessary in
    29  	// the context of running the Mutagen daemon as a launchd service, so it's
    30  	// not necessary for (say) Docker Compose, which isn't used by the daemon.
    31  	return platform.FindCommand("docker", commandSearchPaths)
    32  }