{"record":{"id":"68a519bec6686a79","repo":"wavetermdev/waveterm","slug":"error-copying-wsh-binary-to-remote-w-68a519","errorCode":null,"errorMessage":"error copying wsh binary to remote: %w","messagePattern":"error copying wsh binary to remote: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wslconn/wslconn.go","lineNumber":446,"sourceCode":"\tif client == nil {\n\t\tconn.Infof(ctx, \"ERROR ssh client is not connected, cannot install\\n\")\n\t\treturn fmt.Errorf(\"ssh client is not connected, cannot install\")\n\t}\n\tvar clientOs, clientArch string\n\tvar err error\n\tif osArchStr != \"\" {\n\t\tclientOs, clientArch, err = GetClientPlatformFromOsArchStr(ctx, osArchStr)\n\t} else {\n\t\tclientOs, clientArch, err = GetClientPlatform(ctx, genconn.MakeWSLShellClient(client))\n\t}\n\tif err != nil {\n\t\tconn.Infof(ctx, \"ERROR detecting client platform: %v\\n\", err)\n\t}\n\tconn.Infof(ctx, \"detected remote platform os:%s arch:%s\\n\", clientOs, clientArch)\n\terr = CpWshToRemote(ctx, client, clientOs, clientArch)\n\tif err != nil {\n\t\tconn.Infof(ctx, \"ERROR copying wsh binary to remote: %v\\n\", err)\n\t\treturn fmt.Errorf(\"error copying wsh binary to remote: %w\", err)\n\t}\n\tconn.Infof(ctx, \"successfully installed wsh\\n\")\n\treturn nil\n}\n\nfunc (conn *WslConn) GetClient() *wsl.Distro {\n\tconn.Lock.Lock()\n\tdefer conn.Lock.Unlock()\n\treturn conn.Client\n}\n\nfunc (conn *WslConn) Reconnect(ctx context.Context) error {\n\terr := conn.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn conn.Connect(ctx)\n}","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wslconn/wslconn.go#L428-L464","documentation":"InstallWsh copies the wsh binary into the distro via CpWshToRemote; on failure the cause is wrapped as 'error copying wsh binary to remote: %w'. This fires after platform detection (GetClientPlatform/GetClientPlatformFromOsArchStr), so it reflects a failure in the actual transfer or remote install step, not detection.","triggerScenarios":"Calling InstallWsh when CpWshToRemote fails: unwritable install path in the distro, no wsh build matching the detected clientOs/clientArch, disk full, or the remote command execution errors.","commonSituations":"First-time wsh install on a distro where the target user can't write to the install location; exotic WSL distros (e.g. non-Ubuntu with unusual layout); WSL virtual disk out of space; corrupted download of the wsh artifact.","solutions":["Read the wrapped cause (%w) — fix permissions or free space on the distro's wsh install path","Verify the detected os/arch (logged as 'detected remote platform os:... arch:...') has a matching wsh binary","Reconnect the distro and retry InstallWsh","Manually verify inside the distro that the wsh binary path exists and is executable after a partial install, then retry"],"exampleFix":"// before: silent partial install\nerr := conn.InstallWsh(ctx, osArchStr)\n// after\nif err := conn.InstallWsh(ctx, osArchStr); err != nil {\n    log.Printf(\"install failed, root cause: %v\", errors.Unwrap(err))\n    return err\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := conn.InstallWsh(ctx, osArchStr); err != nil {\n    if strings.Contains(err.Error(), \"error copying wsh binary to remote\") {\n        log.Printf(\"wsh copy failed: %v\", errors.Unwrap(err))\n        // fix permissions/disk, reconnect, retry once\n        _ = conn.Reconnect(ctx)\n        err = conn.InstallWsh(ctx, osArchStr)\n    }\n}","preventionTips":["Verify the detected os/arch is one wsh ships binaries for","Keep the wsh install directory writable by the distro user","Monitor WSL disk usage; a full vhdx breaks binary copies","Log errors.Unwrap to see the concrete copy failure"],"tags":["wsl","wsh","install","copy-failed"],"backgroundTag":"remote-binary-install-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}