Skip to content

Commit 83fdf8e

Browse files
committed
fix(ssh): use /tmp to place control dir on darwin
OpenSSH complains if the control path is too long (>=104) On Darwin, os.MkdirTemp is too long, use /tmp instead. ControlPath too long ('/var/folders/v3/5pnzpycs0pzdpytmgfzc7tj80000gn/T/sock-96855798/sock-b677e145501e220cfb5583ba1638a77ffe779df9' >= 104 bytes) Signed-off-by: Ayman Bagabas <[email protected]>
1 parent 18959fc commit 83fdf8e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ssh/ssh.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package ssh
22

33
import (
44
"fmt"
5-
"io/ioutil"
65
"os"
76
"path/filepath"
87
"regexp"
8+
"runtime"
99
"strings"
1010
"syscall"
1111

@@ -110,9 +110,14 @@ func findRuntimeDir(osEnv config.Environment) string {
110110
}
111111

112112
func getControlDir(osEnv config.Environment) (string, error) {
113+
tmpdir, pattern := "", "sock-*"
114+
if runtime.GOOS == "darwin" {
115+
// On Darwin, the default temporary directory results in a socket path that's too long.
116+
tmpdir = "/tmp"
117+
}
113118
dir := findRuntimeDir(osEnv)
114119
if dir == "" {
115-
return ioutil.TempDir("", "sock-*")
120+
return os.MkdirTemp(tmpdir, pattern)
116121
}
117122
dir = filepath.Join(dir, "git-lfs")
118123
err := os.Mkdir(dir, 0700)
@@ -121,7 +126,7 @@ func getControlDir(osEnv config.Environment) (string, error) {
121126
// os.ErrExist, but that's not available on Go 1.11.
122127
perr, ok := err.(*os.PathError)
123128
if !ok || perr.Err != syscall.EEXIST {
124-
return ioutil.TempDir("", "sock-*")
129+
return os.MkdirTemp(tmpdir, pattern)
125130
}
126131
}
127132
return dir, nil

0 commit comments

Comments
 (0)