wavetermdev/waveterm · error

file does not exist: %q

Error message

file does not exist: %q

What it means

Returned by wsh editor when the specified file path does not exist on disk.

Source

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

	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")
	}

	wshCmd := wshrpc.CommandCreateBlockData{
		TabId: tabId,
		BlockDef: &waveobj.BlockDef{
			Meta: map[string]any{
				waveobj.MetaKey_View: "preview",
				waveobj.MetaKey_File: absFile,
				waveobj.MetaKey_Edit: true,
			},

View on GitHub (pinned to a4447c1563)

Solutions

  1. Verify the path exists (`ls <path>`) and fix typos
  2. Create the file first, or use a different command to create it
  3. Use an absolute path to rule out cwd confusion
  4. Check case sensitivity of the filename

Example fix

// before
wsh editor settngs.json  # typo
// after
wsh editor settings.json
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) {
    return fmt.Errorf("file %q does not exist; create it first", path)
}

Try / catch

if err := wsh.Editor(path); err != nil {
    if strings.Contains(err.Error(), "file does not exist") {
        os.Create(path) // then retry
        err = wsh.Editor(path)
    }
}

Prevention

When it happens

Trigger: Running `wsh editor <path>` where the path does not exist on disk (typo, wrong directory, file deleted, or URL-handling path where a local file was expected).

Common situations: Typos in filenames; editing a file before creating it; paths relative to a different directory than expected; case-sensitivity mismatches on Linux.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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