{"record":{"id":"8786484eac735c5d","repo":"wavetermdev/waveterm","slug":"ssh-client-is-not-connected-cannot-install-878648","errorCode":null,"errorMessage":"ssh client is not connected, cannot install","messagePattern":"ssh client is not connected, cannot install","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wslconn/wslconn.go","lineNumber":430,"sourceCode":"\t\tconn.Infof(ctx, \"writing conn:askbeforewshinstall=false to settings.json\\n\")\n\t\tmeta := waveobj.MetaMapType{\n\t\t\twconfig.ConfigKey_ConnAskBeforeWshInstall: false,\n\t\t}\n\t\tsetConfigErr := wconfig.SetBaseConfigValue(meta)\n\t\tif setConfigErr != nil {\n\t\t\t// this is not a critical error, just log and continue\n\t\t\tlog.Printf(\"warning: error writing to base config file: %v\", err)\n\t\t}\n\t}\n\treturn true, nil\n}\n\nfunc (conn *WslConn) InstallWsh(ctx context.Context, osArchStr string) error {\n\tconn.Infof(ctx, \"running installWsh...\\n\")\n\tclient := conn.GetClient()\n\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\")","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wslconn/wslconn.go#L412-L448","documentation":"InstallWsh requires the underlying *wsl.Distro client to copy the wsh binary into the distro. When conn.GetClient() returns nil there is no active connection handle, so installation cannot proceed and this error is returned immediately (after logging 'ssh client is not connected').","triggerScenarios":"Calling WslConn.InstallWsh (e.g. from tryEnableWsh after StartConnServer reports wsh is missing/outdated) while the distro is disconnected, Connect() hasn't finished, or the client was cleared after a disconnect.","commonSituations":"Auto-install prompt answered while the connection dropped in the background; racing enable-wsh against a reconnect; calling InstallWsh from custom code before ever connecting the distro.","solutions":["Ensure the distro is connected first: conn.Connect(ctx) / conn.Reconnect(ctx), then retry InstallWsh","Gate the call on conn.WaitForConnect(ctx) or a DeriveConnStatus check for Status_Connected","If using tryEnableWsh flow, just retry the connection — wsh install is re-attempted on the next connect"],"exampleFix":"// before\nerr := conn.InstallWsh(ctx, osArchStr)\n// after\nif conn.DeriveConnStatus().Status != Status_Connected {\n    if err := conn.Connect(ctx); err != nil {\n        return err\n    }\n}\nerr := conn.InstallWsh(ctx, osArchStr)","handlingStrategy":"validation","validationCode":"if conn.DeriveConnStatus().Status != Status_Connected {\n    if err := conn.Connect(ctx); err != nil {\n        return fmt.Errorf(\"cannot install wsh: %w\", err)\n    }\n}\n// safe to call InstallWsh now","typeGuard":"func installable(conn *wslconn.WslConn) bool {\n    return conn.DeriveConnStatus().Status == wslconn.Status_Connected\n}","tryCatchPattern":"if err := conn.InstallWsh(ctx, osArchStr); err != nil {\n    if strings.Contains(err.Error(), \"not connected, cannot install\") {\n        return fmt.Errorf(\"reconnect the WSL distro before installing wsh: %w\", err)\n    }\n    return err\n}","preventionTips":["Connect (and WaitForConnect) before any InstallWsh call","Don't race wsh install against Reconnect/Close","Guard auto-install flows with a connected-status check"],"tags":["wsl","wsh","not-connected","install"],"backgroundTag":"ssh-client-not-connected","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}