{"record":{"id":"e6ef4f1b97bdfd24","repo":"wavetermdev/waveterm","slug":"no-waveterm-tabid-env-var-set-e6ef4f","errorCode":null,"errorMessage":"no WAVETERM_TABID env var set","messagePattern":"no WAVETERM_TABID env var set","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-editor.go","lineNumber":60,"sourceCode":"\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"too many arguments.  wsh editor requires exactly one argument\")\n\t}\n\tfileArg := args[0]\n\tabsFile, err := filepath.Abs(fileArg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting absolute path: %w\", err)\n\t}\n\t_, err = os.Stat(absFile)\n\tif err == fs.ErrNotExist {\n\t\treturn fmt.Errorf(\"file does not exist: %q\", absFile)\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting file info: %w\", err)\n\t}\n\n\ttabId := getTabIdFromEnv()\n\tif tabId == \"\" {\n\t\treturn fmt.Errorf(\"no WAVETERM_TABID env var set\")\n\t}\n\n\twshCmd := wshrpc.CommandCreateBlockData{\n\t\tTabId: tabId,\n\t\tBlockDef: &waveobj.BlockDef{\n\t\t\tMeta: map[string]any{\n\t\t\t\twaveobj.MetaKey_View: \"preview\",\n\t\t\t\twaveobj.MetaKey_File: absFile,\n\t\t\t\twaveobj.MetaKey_Edit: true,\n\t\t\t},\n\t\t},\n\t\tMagnified: editMagnified,\n\t\tFocused:   true,\n\t}\n\tif RpcContext.Conn != \"\" {\n\t\twshCmd.BlockDef.Meta[waveobj.MetaKey_Connection] = RpcContext.Conn\n\t}\n\tblockRef, err := wshclient.CreateBlockCommand(RpcClient, wshCmd, &wshrpc.RpcOpts{Timeout: 2000})","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-editor.go#L42-L78","documentation":"`wsh editor` needs to know which Wave terminal tab to open the editor block in. It reads this from the WAVETERM_TABID environment variable (via getTabIdFromEnv). When the variable is empty or unset, editorRun refuses to proceed because it cannot target a block parent.","triggerScenarios":"Running `wsh editor <file>` when WAVETERM_TABID is empty — typically when the command is invoked from a shell that is not a Wave terminal block (plain SSH session, tmux, IDE terminal, CI shell) or from a Wave version that predates tab-id env injection.","commonSituations":"Developers run wsh from an external terminal or over SSH instead of inside a Wave block; the env var was stripped by sudo/tmux/clear-env; an old wsh binary is installed on the remote side and never received the variable.","solutions":["Run the `wsh editor` command from a terminal inside a Wave Terminal block, which sets WAVETERM_TABID automatically.","Verify the variable with `echo $WAVETERM_TABID`; if empty, re-open a new Wave block or check Wave's terminal env injection settings.","If invoking programmatically, set WAVETERM_TABID explicitly in the child process environment to a valid tab id.","Update both local and remote wsh binaries to match your Wave Terminal version so env propagation works."],"exampleFix":"// before (external script)\nssh host 'wsh editor notes.md'\n// after (run inside a Wave block, or pass env)\nssh host 'WAVETERM_TABID=<tabid> wsh editor notes.md'","handlingStrategy":"validation","validationCode":"if os.Getenv(\"WAVETERM_TABID\") == \"\" {\n    return fmt.Errorf(\"not running inside a Wave terminal block; WAVETERM_TABID unset\")\n}","typeGuard":null,"tryCatchPattern":"if err := editorRun(cmd, args); err != nil {\n    if strings.Contains(err.Error(), \"WAVETERM_TABID\") {\n        // fall back to non-block editing (e.g. exec $EDITOR)\n    }\n}","preventionTips":["Only run `wsh editor` from inside a Wave terminal block","Check `echo $WAVETERM_TABID` in scripts before invoking wsh","Avoid sudo/env-stripping wrappers that drop WAVETERM_* variables"],"tags":["cli","environment","wave-terminal"],"backgroundTag":"missing-env-var","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}