{"record":{"id":"0817e1542dcb5edf","repo":"wavetermdev/waveterm","slug":"no-waveterm-tabid-env-var-set-0817e1","errorCode":null,"errorMessage":"no WAVETERM_TABID env var set","messagePattern":"no WAVETERM_TABID env var set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-view.go","lineNumber":58,"sourceCode":"\trootCmd.AddCommand(editCmd)\n}\n\nfunc viewRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tcmdName := cmd.Name()\n\tdefer func() {\n\t\tsendActivity(cmdName, rtnErr == nil)\n\t}()\n\tif len(args) == 0 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"no arguments.  wsh %s requires a file or URL as an argument argument\", cmdName)\n\t}\n\tif len(args) > 1 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"too many arguments.  wsh %s requires exactly one argument\", cmdName)\n\t}\n\ttabId := getTabIdFromEnv()\n\tif tabId == \"\" {\n\t\treturn fmt.Errorf(\"no WAVETERM_TABID env var set\")\n\t}\n\tfileArg := args[0]\n\tconn := RpcContext.Conn\n\tvar wshCmd *wshrpc.CommandCreateBlockData\n\tif strings.HasPrefix(fileArg, \"http://\") || strings.HasPrefix(fileArg, \"https://\") {\n\t\twshCmd = &wshrpc.CommandCreateBlockData{\n\t\t\tTabId: tabId,\n\t\t\tBlockDef: &waveobj.BlockDef{\n\t\t\t\tMeta: map[string]any{\n\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)","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-view.go#L40-L76","documentation":"wsh view opens the new block inside the current Wave tab, which it identifies via the WAVETERM_TABID environment variable that Wave injects into terminal blocks. viewRun calls getTabIdFromEnv(); when the variable is absent or empty the command cannot know where to create the block and fails with this error.","triggerScenarios":"Running `wsh view <path>` where the shell environment lacks WAVETERM_TABID — e.g. inside a plain SSH session on a remote machine without the block context, in a non-Wave terminal, or after manually clearing/exporting the env in a script.","commonSituations":"Running wsh over a raw ssh connection instead of inside a Wave terminal block; running wsh from cron/CI where Wave's env isn't inherited; using `sudo` or `env -i` which strips the variable.","solutions":["Run the command inside a Wave terminal block, where Wave sets WAVETERM_TABID automatically","If using sudo, preserve the var: `sudo --preserve-env=WAVETERM_TABID wsh view file`","Check with `echo $WAVETERM_TABID`; if empty, you are not in a block context and `wsh view` cannot target a tab"],"exampleFix":"// before\n$ ssh host\n$ wsh view notes.md   // no WAVETERM_TABID\n\n// after\n$ # run inside a Wave terminal block (Wave sets WAVETERM_TABID)\n$ wsh view notes.md","handlingStrategy":"validation","validationCode":"if [ -z \"$WAVETERM_TABID\" ]; then echo \"not in a Wave terminal block\" >&2; exit 1; fi\nwsh view \"$TARGET\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run wsh view only inside a Wave terminal block","Avoid sudo/env -i that strips WAVETERM_TABID; use sudo --preserve-env=WAVETERM_TABID","Echo $WAVETERM_TABID to confirm block context before scripted calls"],"tags":["cli","environment-variable","wsh"],"backgroundTag":"missing-env-var","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}