wavetermdev/waveterm · error
no WAVETERM_TABID env var set
Error message
no WAVETERM_TABID env var set
What it means
wsh createblock must know which tab to place the new block in, taken from the WAVETERM_TABID environment variable via getTabIdFromEnv. If the variable is unset or empty, createBlockRun returns this error instead of making an RPC call.
Source
Thrown at cmd/wsh/cmd/wshcmd-createblock.go:39
RunE: createBlockRun,
PreRunE: preRunSetupRpcClient,
Hidden: true,
}
func init() {
createBlockCmd.Flags().BoolVarP(&createBlockMagnified, "magnified", "m", false, "create block in magnified mode")
rootCmd.AddCommand(createBlockCmd)
}
func createBlockRun(cmd *cobra.Command, args []string) error {
viewName := args[0]
var metaSetStrs []string
if len(args) > 1 {
metaSetStrs = args[1:]
}
tabId := getTabIdFromEnv()
if tabId == "" {
return fmt.Errorf("no WAVETERM_TABID env var set")
}
meta, err := parseMetaSets(metaSetStrs)
if err != nil {
return err
}
meta["view"] = viewName
data := wshrpc.CommandCreateBlockData{
TabId: tabId,
BlockDef: &waveobj.BlockDef{
Meta: meta,
},
Magnified: createBlockMagnified,
Focused: true,
}
oref, err := wshclient.CreateBlockCommand(RpcClient, data, nil)
if err != nil {
return fmt.Errorf("create block failed: %v", err)
}View on GitHub (pinned to a4447c1563)
Solutions
- Run the command inside a Wave terminal block so WAVETERM_TABID is set
- Export WAVETERM_TABID manually if invoking from a script: export WAVETERM_TABID=<tabid>
- Avoid env-scrubbing wrappers (sudo -E, env -i, docker exec without -e)
- Use the block controller/other RPC entry points when operating outside a tab context
Example fix
// before ssh host 'wsh createblock editor' # no WAVETERM_TABID on remote shell // after # run inside a Wave block: wsh createblock editor // or export WAVETERM_TABID="$TAB_ID" && wsh createblock editor
Defensive patterns
Strategy: fallback
Validate before calling
if [ -z "$WAVETERM_TABID" ]; then echo "WAVETERM_TABID not set — run inside a Wave terminal block" >&2 exit 1 fi
Try / catch
out, err := runWsh("createblock", view)
if err != nil && strings.Contains(out, "WAVETERM_TABID") {
// fall back: prompt for or look up the tab id, then retry with env set
cmd.Env = append(os.Environ(), "WAVETERM_TABID="+tabId)
} Prevention
- Only run createblock from inside a Wave terminal block
- Don't scrub the environment with sudo/env -i/docker exec without -e
- For remote/automation use, export WAVETERM_TABID explicitly before invoking
- Check `wsh info`-style output to confirm the block context is present
When it happens
Trigger: Running `wsh createblock` outside a Wave terminal block (plain SSH session, external terminal, CI shell) where WAVETERM_TABID is not exported.
Common situations: Running wsh over a raw ssh connection instead of inside a Wave block; a shell that scrubbed the environment (sudo, env -i, docker exec); running in a new tmux/screen session spawned before entering Wave.
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
- create block failed: %v
- no WAVETERM_TABID env var set
- no WAVETERM_TABID env var set
- opening secrets UI: %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/2540d6506be06af4.
Report an issue: GitHub.