@@ -117,9 +117,6 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st
117
117
118
118
binPath ,err := binPath ()
119
119
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
- }
123
120
return xerrors .Errorf ("Failed to get executable path: %w" ,err )
124
121
}
125
122
@@ -159,14 +156,21 @@ func binPath() (string, error) {
159
156
return "" ,xerrors .Errorf ("get executable path: %w" ,err )
160
157
}
161
158
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.
165
163
if runtime .GOOS == "windows" {
166
164
binName := filepath .Base (exePath )
167
165
pathPath ,err := exec .LookPath (exePath )
168
166
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
170
174
}
171
175
172
176
// Warn the user if the current executable is not the same as the one in