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

Commit 74b7fa4

Browse files
committed
Warn if coder-cli not in PATH on Windows
1 parent 2b838a9 commit 74b7fa4

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
@@ -117,9 +117,6 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st
117117

118118
binPath, err := binPath()
119119
if err != nil {
120-
if runtime.GOOS == "windows" {
121-
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)
122-
}
123120
return xerrors.Errorf("Failed to get executable path: %w", err)
124121
}
125122

@@ -159,14 +156,21 @@ func binPath() (string, error) {
159156
return "", xerrors.Errorf("get executable path: %w", err)
160157
}
161158

162-
// On Windows, the coder-cli executable must be in $PATH for Msys2 and Git
163-
// Bash to function correctly. To prevent weird behavior when people switch
164-
// between the two, we require this for all users.
159+
// On Windows, the coder-cli executable must be in $PATH for both Msys2/Git
160+
// Bash and OpenSSH for Windows (used by Powershell and VS Code) to function
161+
// correctly. Check if the current executable is in $PATH, and warn the user
162+
// if it isn't.
165163
if runtime.GOOS == "windows" {
166164
binName := filepath.Base(exePath)
167165
pathPath, err := exec.LookPath(exePath)
168166
if err != nil {
169-
return "", xerrors.Errorf("locate %q in $PATH: %w", binName, err)
167+
clog.LogWarn(
168+
"The current executable is not in $PATH.",
169+
"This may lead to problems connecting to your workspace via SSH.",
170+
fmt.Sprintf("Please move %q to a location in your $PATH (such as System32) and run `%s config-ssh` again.", binName, binName),
171+
)
172+
// Return the exePath so SSH at least works outside of Msys2.
173+
return exePath, nil
170174
}
171175

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

0 commit comments

Comments
 (0)