{"record":{"id":"bd617dab5eb7acbe","repo":"wavetermdev/waveterm","slug":"parent-directory-does-not-exist-q","errorCode":null,"errorMessage":"parent directory does not exist: %q","messagePattern":"parent directory does not exist: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-view.go","lineNumber":86,"sourceCode":"\t\t\t\t\twaveobj.MetaKey_View: \"web\",\n\t\t\t\t\twaveobj.MetaKey_Url:  fileArg,\n\t\t\t\t},\n\t\t\t},\n\t\t\tMagnified: viewMagnified,\n\t\t\tFocused:   true,\n\t\t}\n\t} else {\n\t\tabsFile, err := filepath.Abs(fileArg)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"getting absolute path: %w\", err)\n\t\t}\n\t\tabsParent, err := filepath.Abs(filepath.Dir(fileArg))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"getting absolute path of parent dir: %w\", err)\n\t\t}\n\t\t_, err = os.Stat(absParent)\n\t\tif err == fs.ErrNotExist {\n\t\t\treturn fmt.Errorf(\"parent directory does not exist: %q\", absParent)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"getting file info: %w\", err)\n\t\t}\n\t\twshCmd = &wshrpc.CommandCreateBlockData{\n\t\t\tTabId: tabId,\n\t\t\tBlockDef: &waveobj.BlockDef{\n\t\t\t\tMeta: map[string]interface{}{\n\t\t\t\t\twaveobj.MetaKey_View: \"preview\",\n\t\t\t\t\twaveobj.MetaKey_File: absFile,\n\t\t\t\t},\n\t\t\t},\n\t\t\tMagnified: viewMagnified,\n\t\t\tFocused:   true,\n\t\t}\n\t\tif cmdName == \"edit\" {\n\t\t\twshCmd.BlockDef.Meta[waveobj.MetaKey_Edit] = true\n\t\t}","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-view.go#L68-L104","documentation":"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.","triggerScenarios":"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`.","commonSituations":"Typo'd directory names; referencing a path that exists only on a remote connection while the command stats locally; deleted directories; wrong mount points.","solutions":["Verify the parent dir exists: `ls \"$(dirname <path>)\"`","Correct typos in the path (use shell tab-completion)","If the file lives on a remote, run the command over that connection (`wsh --conn <host> view <path>`) or ensure the path exists locally"],"exampleFix":"// before\n$ wsh view ~/documnets/notes.md\n// error: parent directory does not exist\n\n// after\n$ wsh view ~/documents/notes.md","handlingStrategy":"validation","validationCode":"TARGET=$1\n[ -d \"$(dirname \"$TARGET\")\" ] || { echo \"parent directory does not exist: $(dirname \"$TARGET\")\" >&2; exit 1; }\nwsh view \"$TARGET\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use shell tab-completion to avoid path typos","Stat the path locally first before wsh view","For remote files use the appropriate --conn target instead of a local path"],"tags":["cli","filesystem","missing-file"],"backgroundTag":"file-or-directory-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}