wavetermdev/waveterm · error

parent directory does not exist: %q

Error message

parent directory does not exist: %q

What it means

Before creating the preview block, viewRun stats the computed parent directory (os.Stat(absParent)). If the stat reports fs.ErrNotExist, the file's parent directory does not exist on the local filesystem, meaning the target path cannot be a real file, so the command fails early with this message.

Source

Thrown at cmd/wsh/cmd/wshcmd-view.go:86

					waveobj.MetaKey_View: "web",
					waveobj.MetaKey_Url:  fileArg,
				},
			},
			Magnified: viewMagnified,
			Focused:   true,
		}
	} else {
		absFile, err := filepath.Abs(fileArg)
		if err != nil {
			return fmt.Errorf("getting absolute path: %w", err)
		}
		absParent, err := filepath.Abs(filepath.Dir(fileArg))
		if err != nil {
			return fmt.Errorf("getting absolute path of parent dir: %w", err)
		}
		_, err = os.Stat(absParent)
		if err == fs.ErrNotExist {
			return fmt.Errorf("parent directory does not exist: %q", absParent)
		}
		if err != nil {
			return fmt.Errorf("getting file info: %w", err)
		}
		wshCmd = &wshrpc.CommandCreateBlockData{
			TabId: tabId,
			BlockDef: &waveobj.BlockDef{
				Meta: map[string]interface{}{
					waveobj.MetaKey_View: "preview",
					waveobj.MetaKey_File: absFile,
				},
			},
			Magnified: viewMagnified,
			Focused:   true,
		}
		if cmdName == "edit" {
			wshCmd.BlockDef.Meta[waveobj.MetaKey_Edit] = true
		}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Verify the parent dir exists: `ls "$(dirname <path>)"`
  2. Correct typos in the path (use shell tab-completion)
  3. If the file lives on a remote, run the command over that connection (`wsh --conn <host> view <path>`) or ensure the path exists locally

Example fix

// before
$ wsh view ~/documnets/notes.md
// error: parent directory does not exist

// after
$ wsh view ~/documents/notes.md
Defensive patterns

Strategy: validation

Validate before calling

TARGET=$1
[ -d "$(dirname "$TARGET")" ] || { echo "parent directory does not exist: $(dirname "$TARGET")" >&2; exit 1; }
wsh view "$TARGET"

Prevention

When it happens

Trigger: Running `wsh view <path>` where the path's parent directory doesn't exist locally, e.g. `wsh view /nonexistent/dir/file.txt` or a typo like `wsh view ~/documnets/notes.md`.

Common situations: Typo'd directory names; referencing a path that exists only on a remote connection while the command stats locally; deleted directories; wrong mount points.

Related errors


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