{"record":{"id":"06bf0eff4ac95219","repo":"wavetermdev/waveterm","slug":"cannot-open-local-file-s-w","errorCode":null,"errorMessage":"cannot open local file %s: %w","messagePattern":"cannot open local file (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/remote/connutil.go","lineNumber":111,"sourceCode":"mkdir -p {{.installDir}} || exit 1;\ncat > {{.tempPath}} || exit 1;\nmv {{.tempPath}} {{.installPath}} || exit 1;\nchmod a+x {{.installPath}} || exit 1;\n`)\nvar installTemplate = template.Must(template.New(\"wsh-install-template\").Parse(installTemplateRawDefault))\n\nfunc CpWshToRemote(ctx context.Context, client *ssh.Client, clientOs string, clientArch string) error {\n\tdeadline, ok := ctx.Deadline()\n\tif ok {\n\t\tblocklogger.Debugf(ctx, \"[conndebug] CpWshToRemote, timeout: %v\\n\", time.Until(deadline))\n\t}\n\twshLocalPath, err := shellutil.GetLocalWshBinaryPath(wavebase.WaveVersion, clientOs, clientArch)\n\tif err != nil {\n\t\treturn err\n\t}\n\tinput, err := os.Open(wshLocalPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot open local file %s: %w\", wshLocalPath, err)\n\t}\n\tdefer input.Close()\n\tinstallWords := map[string]string{\n\t\t\"installDir\":  filepath.ToSlash(filepath.Dir(wavebase.RemoteFullWshBinPath)),\n\t\t\"tempPath\":    wavebase.RemoteFullWshBinPath + \".temp\",\n\t\t\"installPath\": wavebase.RemoteFullWshBinPath,\n\t}\n\tvar installCmd bytes.Buffer\n\tif err := installTemplate.Execute(&installCmd, installWords); err != nil {\n\t\treturn fmt.Errorf(\"failed to prepare install command: %w\", err)\n\t}\n\tblocklogger.Infof(ctx, \"[conndebug] copying %q to remote server %q\\n\", wshLocalPath, wavebase.RemoteFullWshBinPath)\n\tgenCmd, err := genconn.MakeSSHCmdClient(client, genconn.CommandSpec{\n\t\tCmd: installCmd.String(),\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create remote command: %w\", err)\n\t}","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/remote/connutil.go#L93-L129","documentation":"CpWshToRemote copies the locally installed wsh binary to a remote host. This error is wrapped when os.Open fails on the local wsh binary path computed by shellutil.GetLocalWshBinaryPath for the current Wave version and the detected client OS/arch. It means the binary to upload is missing or unreadable on the local machine, so the remote install cannot proceed.","triggerScenarios":"Calling CpWshToRemote (via UpdateWsh or InstallWsh) when the local wsh binary file does not exist at the version/arch-derived path, the file permissions deny read, or the binary was deleted/moved after install.","commonSituations":"Running a dev build where the wsh binary was never placed at the expected path; mismatched clientOs/clientArch causing a lookup of a binary variant not shipped; antivirus quarantining the binary; partial upgrades removing old-version binaries.","solutions":["Check that the file printed in the error message exists (ls) and is readable; reinstall/repair Wave Terminal to restore the wsh binary.","Verify the clientOs/clientArch passed to CpWshToRemote are correct — a wrong arch makes GetLocalWshBinaryPath point at a non-existent variant.","Rebuild the wsh binary for the target platform if running from source, placing it where GetLocalWshBinaryPath expects.","Check file permissions and AV quarantine logs if the path exists but cannot be opened."],"exampleFix":"// before\n_, err := connutil.CpWshToRemote(ctx, client, clientOs, \"armv7\") // variant not shipped locally\n// after\nif _, err := os.Stat(localPath); os.IsNotExist(err) {\n    return fmt.Errorf(\"wsh binary missing for %s/%s; reinstall Wave\", clientOs, clientArch)\n}\nerr := connutil.CpWshToRemote(ctx, client, clientOs, clientArch)","handlingStrategy":"validation","validationCode":"p, err := shellutil.GetLocalWshBinaryPath(wavebase.WaveVersion, clientOs, clientArch)\nif err != nil { return err }\nif fi, err := os.Stat(p); err != nil || fi.IsDir() {\n    return fmt.Errorf(\"local wsh binary missing at %s for %s/%s\", p, clientOs, clientArch)\n}","typeGuard":null,"tryCatchPattern":"err := connutil.CpWshToRemote(ctx, client, clientOs, clientArch)\nif err != nil && strings.Contains(err.Error(), \"cannot open local file\") {\n    return fmt.Errorf(\"wsh binary not installed locally; reinstall Wave Terminal: %w\", err)\n}","preventionTips":["Verify the wsh binary exists for the current version/arch before offering install/update actions.","Keep clientOs/clientArch values consistent with the binaries actually shipped.","Exclude the wsh binary path from antivirus/cleanup tooling.","Rebuild/restore binaries after upgrading Wave from source."],"tags":["go","filesystem","wsh","installation"],"backgroundTag":"file-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}