From 43e12c135b0de65a9000842539bc4afad82874d5 Mon Sep 17 00:00:00 2001 From: Clivar <16317699+Clivar@users.noreply.github.com> Date: Sun, 12 Jun 2022 23:44:00 +0200 Subject: Fix #14416: Use absolute path to WSL binary to create ssh keys for `machine init` Signed-off-by: Clivar <16317699+Clivar@users.noreply.github.com> --- pkg/machine/keys.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'pkg/machine') diff --git a/pkg/machine/keys.go b/pkg/machine/keys.go index 15c1f73d8..45d9801cc 100644 --- a/pkg/machine/keys.go +++ b/pkg/machine/keys.go @@ -59,7 +59,16 @@ func generatekeysPrefix(dir string, file string, passThru bool, prefix ...string args := append([]string{}, prefix[1:]...) args = append(args, sshCommand...) args = append(args, file) - cmd := exec.Command(prefix[0], args...) + + binary, err := exec.LookPath(prefix[0]) + if err != nil { + return err + } + binary, err = filepath.Abs(binary) + if err != nil { + return err + } + cmd := exec.Command(binary, args...) cmd.Dir = dir if passThru { cmd.Stdin = os.Stdin -- cgit v1.2.3-54-g00ecf