{"record":{"id":"2397f482da75dfa4","repo":"wavetermdev/waveterm","slug":"removing-file-w","errorCode":null,"errorMessage":"removing file: %w","messagePattern":"removing file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-file.go","lineNumber":235,"sourceCode":"\t\t\tWriteStdout(\"\\t\\t\\t%s: %v\\n\", k, v)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc fileRmRun(cmd *cobra.Command, args []string) error {\n\tpath, err := fixRelativePaths(args[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\trecursive, err := cmd.Flags().GetBool(\"recursive\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = wshclient.FileDeleteCommand(RpcClient, wshrpc.CommandDeleteFileData{Path: path, Recursive: recursive}, &wshrpc.RpcOpts{Timeout: fileTimeout})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"removing file: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc fileWriteRun(cmd *cobra.Command, args []string) error {\n\tpath, err := fixRelativePaths(args[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\tfileData := wshrpc.FileData{\n\t\tInfo: &wshrpc.FileInfo{\n\t\t\tPath: path}}\n\n\tlimitReader := io.LimitReader(WrappedStdin, MaxFileSize+1)\n\tdata, err := io.ReadAll(limitReader)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading input: %w\", err)","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-file.go#L217-L253","documentation":"fileRmRun issues FileDeleteCommand over RPC and wraps any failure with 'removing file:'. Deletion failures surface here when the RPC itself fails or the remote refuses the delete (permissions, non-empty directory without --recursive).","triggerScenarios":"`wsh file rm <path>` (with or without --recursive) where: the remote host is unreachable, the path does not exist or is not writable, deleting a non-empty directory without --recursive, or the RPC times out.","commonSituations":"rm a directory that still has contents without -r, removing root-owned files as a non-privileged remote user, remote connection dropped mid-delete, stale wsh server after an update.","solutions":["Add --recursive when deleting a non-empty directory.","Verify permissions/ownership on the remote file (`wsh file info <path>`) and run as a user allowed to delete it.","Confirm connectivity to the remote host and retry; update the remote wsh if versions mismatch.","Check the wrapped inner error for the concrete cause (not-found vs permission vs timeout)."],"exampleFix":"// before\nwsh file rm wsh://user@ec2/logs/app\n// after\nwsh file rm --recursive wsh://user@ec2/logs/app","handlingStrategy":"validation","validationCode":"info, err := wshclient.FileInfoCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout})\nif err != nil || info.NotFound {\n    return fmt.Errorf(\"nothing to delete at %s\", path)\n}\nif info.IsDir && !recursive && !info.CanDelete {\n    return fmt.Errorf(\"directory not empty; use --recursive\")\n}","typeGuard":null,"tryCatchPattern":"err := wshclient.FileDeleteCommand(RpcClient, wshrpc.CommandDeleteFileData{Path: path, Recursive: recursive}, &wshrpc.RpcOpts{Timeout: fileTimeout})\nif err != nil {\n    if strings.Contains(err.Error(), \"directory not empty\") && !recursive {\n        // retry with recursive=true after confirmation\n    }\n    return fmt.Errorf(\"removing file: %w\", err)\n}","preventionTips":["Use --recursive for directories; stat the target first with `wsh file info`.","Check remote permissions/ownership before deleting root-owned files.","Avoid deleting over flaky connections; verify connectivity first."],"tags":["go","wsh","file-delete","rpc"],"backgroundTag":"file-delete-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}