Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit d7b7db4

Browse files
committed
Warn if coder-cli not in PATH on Windows
1 parent 9e56e79 commit d7b7db4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

internal/cmd/configssh.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ func configSSH(configpath *string, remove *bool, next *bool) func(cmd *cobra.Com
136136

137137
binPath, err := binPath()
138138
if err != nil {
139-
if runtime.GOOS == "windows" {
140-
return xerrors.Errorf("Failed to ensure `coder` is in $PATH, please move the `coder` binary to a location in $PATH (such as System32): %w", err)
141-
}
142139
return xerrors.Errorf("Failed to get executable path: %w", err)
143140
}
144141

@@ -178,14 +175,21 @@ func binPath() (string, error) {
178175
return "", xerrors.Errorf("get executable path: %w", err)
179176
}
180177

181-
// On Windows, the coder-cli executable must be in $PATH for Msys2 and Git
182-
// Bash to function correctly. To prevent weird behavior when people switch
183-
// between the two, we require this for all users.
178+
// On Windows, the coder-cli executable must be in $PATH for both Msys2/Git
179+
// Bash and OpenSSH for Windows (used by Powershell and VS Code) to function
180+
// correctly. Check if the current executable is in $PATH, and warn the user
181+
// if it isn't.
184182
if runtime.GOOS == "windows" {
185183
binName := filepath.Base(exePath)
186184
pathPath, err := exec.LookPath(exePath)
187185
if err != nil {
188-
return "", xerrors.Errorf("locate %q in $PATH: %w", binName, err)
186+
clog.LogWarn(
187+
"The current executable is not in $PATH.",
188+
"This may lead to problems connecting to your workspace via SSH.",
189+
fmt.Sprintf("Please move %q to a location in your $PATH (such as System32) and run `%s config-ssh` again.", binName, binName),
190+
)
191+
// Return the exePath so SSH at least works outside of Msys2.
192+
return exePath, nil
189193
}
190194

191195
// Warn the user if the current executable is not the same as the one in

0 commit comments

Comments
 (0)