wavetermdev/waveterm · error

no WAVETERM_TABID env var set

Error message

no WAVETERM_TABID env var set

What it means

webOpenRun needs the current tab id to create the web block; it reads it from the WAVETERM_TABID environment variable via getTabIdFromEnv(). If the variable is empty, the command cannot know where to create the block and errors out.

Source

Thrown at cmd/wsh/cmd/wshcmd-web.go:117

	defer func() {
		sendActivity("web", rtnErr == nil)
	}()

	var replaceBlockORef *waveobj.ORef
	if webOpenReplaceBlock != "" {
		var err error
		replaceBlockORef, err = resolveSimpleId(webOpenReplaceBlock)
		if err != nil {
			return fmt.Errorf("resolving -r blockid: %w", err)
		}
	}
	if replaceBlockORef != nil && webOpenMagnified {
		return fmt.Errorf("cannot use --replace and --magnified together")
	}

	tabId := getTabIdFromEnv()
	if tabId == "" {
		return fmt.Errorf("no WAVETERM_TABID env var set")
	}

	wshCmd := wshrpc.CommandCreateBlockData{
		TabId: tabId,
		BlockDef: &waveobj.BlockDef{
			Meta: map[string]any{
				waveobj.MetaKey_View: "web",
				waveobj.MetaKey_Url:  args[0],
			},
		},
		Magnified: webOpenMagnified,
		Focused:   true,
	}
	if replaceBlockORef != nil {
		wshCmd.TargetBlockId = replaceBlockORef.OID
		wshCmd.TargetAction = wshrpc.CreateBlockAction_Replace
	}
	oref, err := wshclient.CreateBlockCommand(RpcClient, wshCmd, nil)

View on GitHub (pinned to a4447c1563)

Solutions

  1. Run the command from a terminal inside Wave Terminal so WAVETERM_TABID is exported
  2. Export WAVETERM_TABID manually with a valid tab id if scripting
  3. Use --blockid/--replace with an explicit block when tab context is unavailable

Example fix

// before (plain shell)
wsh web open https://example.com
// after
export WAVETERM_TABID=<tab-id> && wsh web open https://example.com
Defensive patterns

Strategy: validation

Validate before calling

if os.Getenv("WAVETERM_TABID") == "" {
    return errors.New("run from a Wave Terminal tab or set WAVETERM_TABID")
}

Prevention

When it happens

Trigger: Running `wsh web open <url>` from a plain terminal, SSH session, or CI shell where the wsh invocation is not attached to a Wave Terminal tab (WAVETERM_TABID unset).

Common situations: Running wsh from outside the integrated terminal; env vars lost via sudo/su or a different user; remote wsh usage without the connection context.

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


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