wavetermdev/waveterm · error

too many arguments. wsh editor requires exactly one argumen

Error message

too many arguments.  wsh editor requires exactly one argument

What it means

Returned by wsh editor when more than one argument is given; the command accepts exactly one file or URL.

Source

Thrown at cmd/wsh/cmd/wshcmd-editor.go:43

	PreRunE: preRunSetupRpcClient,
}

func init() {
	editorCmd.Flags().BoolVarP(&editMagnified, "magnified", "m", false, "open view in magnified mode")
	rootCmd.AddCommand(editorCmd)
}

func editorRun(cmd *cobra.Command, args []string) (rtnErr error) {
	defer func() {
		sendActivity("editor", rtnErr == nil)
	}()
	if len(args) == 0 {
		OutputHelpMessage(cmd)
		return fmt.Errorf("no arguments.  wsh editor requires a file or URL as an argument argument")
	}
	if len(args) > 1 {
		OutputHelpMessage(cmd)
		return fmt.Errorf("too many arguments.  wsh editor requires exactly one argument")
	}
	fileArg := args[0]
	absFile, err := filepath.Abs(fileArg)
	if err != nil {
		return fmt.Errorf("getting absolute path: %w", err)
	}
	_, err = os.Stat(absFile)
	if err == fs.ErrNotExist {
		return fmt.Errorf("file does not exist: %q", absFile)
	}
	if err != nil {
		return fmt.Errorf("getting file info: %w", err)
	}

	tabId := getTabIdFromEnv()
	if tabId == "" {
		return fmt.Errorf("no WAVETERM_TABID env var set")
	}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Pass only one file or URL argument
  2. Quote paths containing spaces: `wsh editor "my file.txt"`
  3. Open additional files with separate invocations

Example fix

// before
wsh editor my file.txt
// after
wsh editor "my file.txt"
Defensive patterns

Strategy: validation

Validate before calling

if len(args) > 1 {
    return errors.New("wsh editor accepts exactly one argument; quote paths with spaces")
}

Prevention

When it happens

Trigger: Running `wsh editor file1 file2` or passing extra flags/words that cobra does not consume as flags.

Common situations: Trying to open multiple files at once (not supported); an unquoted path containing spaces being split into two args.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/eb0d5f29c8cb930e. Report an issue: GitHub.