{"record":{"id":"7ecb0f05647fd883","repo":"wavetermdev/waveterm","slug":"error-running-uname-sm-w-stderr-s","errorCode":null,"errorMessage":"error running uname -sm: %w, stderr: %s","messagePattern":"error running uname -sm: %w, stderr: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/remote/connutil.go","lineNumber":66,"sourceCode":"\tarch = strings.ToLower(strings.TrimSpace(arch))\n\tswitch arch {\n\tcase \"x86_64\", \"amd64\":\n\t\tarch = \"x64\"\n\tcase \"arm64\", \"aarch64\":\n\t\tarch = \"arm64\"\n\t}\n\treturn arch\n}\n\n// returns (os, arch, error)\n// guaranteed to return a supported platform\nfunc GetClientPlatform(ctx context.Context, shell genconn.ShellClient) (string, string, error) {\n\tblocklogger.Infof(ctx, \"[conndebug] running `uname -sm` to detect client platform\\n\")\n\tstdout, stderr, err := genconn.RunSimpleCommand(ctx, shell, genconn.CommandSpec{\n\t\tCmd: \"uname -sm\",\n\t})\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"error running uname -sm: %w, stderr: %s\", err, stderr)\n\t}\n\t// Parse and normalize output\n\tparts := strings.Fields(strings.ToLower(strings.TrimSpace(stdout)))\n\tif len(parts) != 2 {\n\t\treturn \"\", \"\", fmt.Errorf(\"unexpected output from uname: %s\", stdout)\n\t}\n\tos, arch := normalizeOs(parts[0]), normalizeArch(parts[1])\n\tif err := wavebase.ValidateWshSupportedArch(os, arch); err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\treturn os, arch, nil\n}\n\nfunc GetClientPlatformFromOsArchStr(ctx context.Context, osArchStr string) (string, string, error) {\n\tparts := strings.Fields(strings.TrimSpace(osArchStr))\n\tif len(parts) != 2 {\n\t\treturn \"\", \"\", fmt.Errorf(\"unexpected output from uname: %s\", osArchStr)\n\t}","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/remote/connutil.go#L48-L84","documentation":"GetClientPlatform runs 'uname -sm' on the remote host via the provided genconn.ShellClient to detect its OS/architecture. This error is wrapped when the command itself fails to execute or returns a non-zero exit, with the captured stderr included for diagnosis. It means platform detection could not be performed, not that the output was malformed (see the 'unexpected output' error for that).","triggerScenarios":"genconn.RunSimpleCommand returns an error while running 'uname -sm' — e.g. SSH connection dropped mid-command, remote shell cannot spawn, 'uname' not on PATH (minimal containers/non-POSIX systems), or the command timed out.","commonSituations":"Installing/updating wsh (InstallWsh) on remote hosts lacking standard Unix tools (Alpine variants without coreutils in PATH, Windows targets); flaky SSH connections; restricted shells (rbash) blocking command execution.","solutions":["Inspect the stderr embedded in the message to identify the remote-side failure (command not found, permission denied, etc.).","Verify the remote host is a POSIX system with 'uname' available in the default shell PATH.","Re-check SSH connectivity and retry InstallWsh; transient network drops surface here.","If the remote is non-POSIX, use GetClientPlatformFromOsArchStr with a manually supplied os/arch string instead."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify connectivity before platform detection\nstdout, stderr, err := genconn.RunSimpleCommand(ctx, shell, genconn.CommandSpec{Cmd: \"echo ok\"})\nif err != nil || strings.TrimSpace(stdout) != \"ok\" {\n    return fmt.Errorf(\"remote shell unavailable: %v %s\", err, stderr)\n}","typeGuard":null,"tryCatchPattern":"os, arch, err := connutil.GetClientPlatform(ctx, shell)\nif err != nil {\n    if strings.Contains(err.Error(), \"error running uname\") {\n        // retry once, then fall back to a manual os/arch\n        os, arch, err = connutil.GetClientPlatformFromOsArchStr(ctx, knownOsArch)\n    }\n    if err != nil { return err }\n}","preventionTips":["Confirm the remote host is POSIX with 'uname' available before running wsh install.","Keep SSH connections warm or reconnect on failure before invoking GetClientPlatform.","Log the embedded stderr to diagnose remote-side shell problems quickly.","Provide a manual os/arch override for non-standard remote environments."],"tags":["go","ssh","remote-execution","platform-detection"],"backgroundTag":"remote-command-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}