Description
When attempting to connect or reinstall a connection (wsh conn reinstall) to a remote target that runs on Windows OS (with native OpenSSH server enabled), the process fails during client platform detection. The terminal prints a corrupted, unreadable error message:
Error: reinstalling connection: error detecting client platform: error running uname -sm: Process exited with status 1, stderr: 'sh'() Ǵ , α, Ǵ ġ ƴմϴ.
Root Cause Analysis
-
Decoding Error (CP949 to UTF-8)
The unreadable message 'sh'() Ǵ , α, Ǵ ġ ƴմϴ. is the CP949-encoded Windows Command Prompt/PowerShell error message decoded as UTF-8 in Go. The original Korean error message is:
'sh'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다.
(English translation: 'sh' is not recognized as an internal or external command, operable program or batch file.)
-
Hardcoded sh -c wrapper
In the Go source code, when detecting the platform of the remote machine:
-
In pkg/remote/connutil.go inside GetClientPlatform, uname -sm is run to determine the target OS and architecture.
-
However, in pkg/genconn/genconn.go inside BuildShellCommand, all remote shell commands are wrapped in sh -c by default:
return fmt.Sprintf("sh -c %s", shellutil.HardQuote(envVars.String()+shellCmd)), nil
-
Since a Windows host does not have sh installed in its %PATH% by default, executing sh -c 'uname -sm' fails immediately with the Windows command-not-found error.
Environment
- Client OS: Windows/Linux/macOS
- Remote Target OS: Windows (running OpenSSH)
- Wave Terminal / wsh version: v0.14.5
Suggested Mitigation / Fixes
- Detection fallback: If
sh fails or is missing, try executing commands via cmd.exe /c or powershell -Command when targeting Windows hosts, or allow specifying the shell/OS configuration beforehand.
- Graceful parsing: Handle different shell error codes and decoding errors (like CP949 fallback for Windows targets) to show friendly messages when the shell invocation fails.
Description
When attempting to connect or reinstall a connection (
wsh conn reinstall) to a remote target that runs on Windows OS (with native OpenSSH server enabled), the process fails during client platform detection. The terminal prints a corrupted, unreadable error message:Root Cause Analysis
Decoding Error (CP949 to UTF-8)
The unreadable message
'sh'() Ǵ , α, Ǵ ġ ƴմϴ.is the CP949-encoded Windows Command Prompt/PowerShell error message decoded as UTF-8 in Go. The original Korean error message is:'sh'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다.(English translation:
'sh'is not recognized as an internal or external command, operable program or batch file.)Hardcoded
sh -cwrapperIn the Go source code, when detecting the platform of the remote machine:
In
pkg/remote/connutil.goinsideGetClientPlatform,uname -smis run to determine the target OS and architecture.However, in
pkg/genconn/genconn.goinsideBuildShellCommand, all remote shell commands are wrapped insh -cby default:Since a Windows host does not have
shinstalled in its%PATH%by default, executingsh -c 'uname -sm'fails immediately with the Windows command-not-found error.Environment
Suggested Mitigation / Fixes
shfails or is missing, try executing commands viacmd.exe /corpowershell -Commandwhen targeting Windows hosts, or allow specifying the shell/OS configuration beforehand.