wavetermdev/waveterm · error
removing file: %w
Error message
removing file: %w
What it means
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).
Source
Thrown at cmd/wsh/cmd/wshcmd-file.go:235
WriteStdout("\t\t\t%s: %v\n", k, v)
}
}
return nil
}
func fileRmRun(cmd *cobra.Command, args []string) error {
path, err := fixRelativePaths(args[0])
if err != nil {
return err
}
recursive, err := cmd.Flags().GetBool("recursive")
if err != nil {
return err
}
err = wshclient.FileDeleteCommand(RpcClient, wshrpc.CommandDeleteFileData{Path: path, Recursive: recursive}, &wshrpc.RpcOpts{Timeout: fileTimeout})
if err != nil {
return fmt.Errorf("removing file: %w", err)
}
return nil
}
func fileWriteRun(cmd *cobra.Command, args []string) error {
path, err := fixRelativePaths(args[0])
if err != nil {
return err
}
fileData := wshrpc.FileData{
Info: &wshrpc.FileInfo{
Path: path}}
limitReader := io.LimitReader(WrappedStdin, MaxFileSize+1)
data, err := io.ReadAll(limitReader)
if err != nil {
return fmt.Errorf("reading input: %w", err)View on GitHub (pinned to a4447c1563)
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).
Example fix
// before wsh file rm wsh://user@ec2/logs/app // after wsh file rm --recursive wsh://user@ec2/logs/app
Defensive patterns
Strategy: validation
Validate before calling
info, err := wshclient.FileInfoCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout})
if err != nil || info.NotFound {
return fmt.Errorf("nothing to delete at %s", path)
}
if info.IsDir && !recursive && !info.CanDelete {
return fmt.Errorf("directory not empty; use --recursive")
} Try / catch
err := wshclient.FileDeleteCommand(RpcClient, wshrpc.CommandDeleteFileData{Path: path, Recursive: recursive}, &wshrpc.RpcOpts{Timeout: fileTimeout})
if err != nil {
if strings.Contains(err.Error(), "directory not empty") && !recursive {
// retry with recursive=true after confirmation
}
return fmt.Errorf("removing file: %w", err)
} Prevention
- 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.
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- nil wshrpc passed to wshclient
- no route id available
- starting file stream: %w
- getting file info: %w
- unable to obtain client info: %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/2397f482da75dfa4.
Report an issue: GitHub.