wavetermdev/waveterm · error
no WAVETERM_TABID env var set
Error message
no WAVETERM_TABID env var set
What it means
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.
Source
Thrown at cmd/wsh/cmd/wshcmd-view.go:58
rootCmd.AddCommand(editCmd)
}
func viewRun(cmd *cobra.Command, args []string) (rtnErr error) {
cmdName := cmd.Name()
defer func() {
sendActivity(cmdName, rtnErr == nil)
}()
if len(args) == 0 {
OutputHelpMessage(cmd)
return fmt.Errorf("no arguments. wsh %s requires a file or URL as an argument argument", cmdName)
}
if len(args) > 1 {
OutputHelpMessage(cmd)
return fmt.Errorf("too many arguments. wsh %s requires exactly one argument", cmdName)
}
tabId := getTabIdFromEnv()
if tabId == "" {
return fmt.Errorf("no WAVETERM_TABID env var set")
}
fileArg := args[0]
conn := RpcContext.Conn
var wshCmd *wshrpc.CommandCreateBlockData
if strings.HasPrefix(fileArg, "http://") || strings.HasPrefix(fileArg, "https://") {
wshCmd = &wshrpc.CommandCreateBlockData{
TabId: tabId,
BlockDef: &waveobj.BlockDef{
Meta: map[string]any{
waveobj.MetaKey_View: "web",
waveobj.MetaKey_Url: fileArg,
},
},
Magnified: viewMagnified,
Focused: true,
}
} else {
absFile, err := filepath.Abs(fileArg)View on GitHub (pinned to a4447c1563)
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
Example fix
// before $ ssh host $ wsh view notes.md // no WAVETERM_TABID // after $ # run inside a Wave terminal block (Wave sets WAVETERM_TABID) $ wsh view notes.md
Defensive patterns
Strategy: validation
Validate before calling
if [ -z "$WAVETERM_TABID" ]; then echo "not in a Wave terminal block" >&2; exit 1; fi wsh view "$TARGET"
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- WAVETERM_TABID environment variable not set
- no files or message provided
- too many files (maximum %d files allowed)
- stdin (-) can only be used once
- resolving block: %v
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/0817e1542dcb5edf.
Report an issue: GitHub.