{"record":{"id":"d6da0df5347b9753","repo":"wavetermdev/waveterm","slug":"cannot-expand-wsh-path-w","errorCode":null,"errorMessage":"cannot expand wsh path: %w","messagePattern":"cannot expand wsh path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshrpc/wshremote/wshremote.go","lineNumber":136,"sourceCode":"\n\tif err := os.MkdirAll(symlinkDir, 0700); err != nil {\n\t\treturn fmt.Errorf(\"could not create client directory %s: %w\", symlinkDir, err)\n\t}\n\tos.Remove(symlinkPath)\n\tif err := os.Symlink(impl.SockName, symlinkPath); err != nil {\n\t\treturn fmt.Errorf(\"could not create symlink %s -> %s: %w\", symlinkPath, impl.SockName, err)\n\t}\n\timpl.Log(\"created symlink %s -> %s\\n\", symlinkPath, impl.SockName)\n\treturn nil\n}\n\nfunc (impl *ServerImpl) getWshPath() (string, error) {\n\tif impl.IsLocal {\n\t\treturn filepath.Join(wavebase.GetWaveDataDir(), \"bin\", \"wsh\"), nil\n\t}\n\twshPath, err := wavebase.ExpandHomeDir(\"~/.waveterm/bin/wsh\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"cannot expand wsh path: %w\", err)\n\t}\n\treturn wshPath, nil\n}\n\nfunc (impl *ServerImpl) BadgeWatchPidCommand(ctx context.Context, data wshrpc.CommandBadgeWatchPidData) error {\n\tif data.Pid <= 0 {\n\t\treturn fmt.Errorf(\"invalid pid: %d\", data.Pid)\n\t}\n\tif data.ORef.IsEmpty() {\n\t\treturn fmt.Errorf(\"oref is required\")\n\t}\n\tif data.BadgeId == \"\" {\n\t\treturn fmt.Errorf(\"badgeid is required\")\n\t}\n\tgo func() {\n\t\tdefer func() {\n\t\t\tpanichandler.PanicHandler(\"BadgeWatchPidCommand\", recover())\n\t\t}()","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshrpc/wshremote/wshremote.go#L118-L154","documentation":"getWshPath failed expanding '~/.waveterm/bin/wsh' via wavebase.ExpandHomeDir for a remote server, meaning the user's home directory could not be resolved on the remote host. Used by RemoteStartJobCommand to locate the remote wsh binary.","triggerScenarios":"Calling RemoteStartJobCommand on a remote connection where ExpandHomeDir('~/.waveterm/bin/wsh') errors — HOME unset or unparseable for the SSH user.","commonSituations":"SSH into accounts with no/odd HOME env (restricted shells, nologin users), sftp-only chrooted accounts, Windows remote without proper HOME mapping.","solutions":["Ensure HOME is set for the SSH user on the remote host","Use a normal shell account rather than a chrooted/restricted one","Verify wavebase.ExpandHomeDir behavior for the target platform","Note: only non-local servers hit this path; local builds return the data dir directly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"out, err := runOnRemote(\"echo $HOME\")\nif err != nil || strings.TrimSpace(out) == \"\" {\n    return fmt.Errorf(\"remote HOME not set; cannot resolve wsh path\")\n}","typeGuard":null,"tryCatchPattern":"path, err := impl.getWshPath()\nif err != nil {\n    return fmt.Errorf(\"remote wsh unavailable (check HOME on remote): %w\", err)\n}","preventionTips":["Use SSH accounts with a real login shell and HOME set","Avoid chrooted/sftp-only accounts for remote connections","Test remote connectivity with a command that reads $HOME first"],"tags":["go","remote","path","home-dir"],"backgroundTag":"home-dir-not-resolvable","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}