From f350b61ebb56daa28c7d3b452d60b7cf94e2adef Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Sat, 26 Aug 2023 12:03:05 -0600 Subject: [PATCH] Use magic path for ssh-agent on darwin. --- internal/command/docker.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/command/docker.go b/internal/command/docker.go index 2559beb..19c6a78 100644 --- a/internal/command/docker.go +++ b/internal/command/docker.go @@ -139,7 +139,12 @@ func (i *localContainerImage) cmd(vol volume.Volume, opts options, cmdArgs []str // detect ssh-agent socket for private repositories access if sshAuthSock := os.Getenv("SSH_AUTH_SOCK"); sshAuthSock != "" { - if realSshAuthSock, err := filepath.EvalSymlinks(sshAuthSock); err == nil { + if runtime.GOOS == "darwin" { + // on macOS, the SSH_AUTH_SOCK is not available in the container directly, + // but instead we need to the magic path "/run/host-services/ssh-auth.sock" + args = append(args, "-v", "/run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock") + args = append(args, "-e", "SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock") + } else if realSshAuthSock, err := filepath.EvalSymlinks(sshAuthSock); err == nil { args = append(args, "-v", fmt.Sprintf("%s:/tmp/ssh-agent", realSshAuthSock)) args = append(args, "-e", "SSH_AUTH_SOCK=/tmp/ssh-agent") }