wavetermdev/waveterm · error

no WAVETERM_TABID env var set

Error message

no WAVETERM_TABID env var set

What it means

editConfigRun needs a tab id to create the config editor block in the current tab, obtained from the WAVETERM_TABID environment variable. When wsh is run outside a Wave terminal block (or the var is unset), getTabIdFromEnv returns "" and this error is returned instead of creating the block.

Source

Thrown at cmd/wsh/cmd/wshcmd-editconfig.go:43

func init() {
	editConfigCmd.Flags().BoolVarP(&editConfigMagnified, "magnified", "m", false, "open config in magnified mode")
	rootCmd.AddCommand(editConfigCmd)
}

func editConfigRun(cmd *cobra.Command, args []string) (rtnErr error) {
	defer func() {
		sendActivity("editconfig", rtnErr == nil)
	}()

	configFile := "settings.json" // default
	if len(args) > 0 {
		configFile = args[0]
	}

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

	wshCmd := &wshrpc.CommandCreateBlockData{
		TabId: tabId,
		BlockDef: &waveobj.BlockDef{
			Meta: map[string]interface{}{
				waveobj.MetaKey_View: "waveconfig",
				waveobj.MetaKey_File: configFile,
			},
		},
		Magnified: editConfigMagnified,
		Focused:   true,
	}

	_, err := wshclient.CreateBlockCommand(RpcClient, *wshCmd, &wshrpc.RpcOpts{Timeout: 2000})
	if err != nil {
		return fmt.Errorf("opening config file: %w", err)
	}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Run `wsh editconfig` inside a Wave terminal block where WAVETERM_TABID is set
  2. Set WAVETERM_TABID to a valid tab id before invoking the command
  3. Use `wsh settab` context or edit ~/.config/waveterm/settings.json directly with a normal editor

Example fix

// before
$ plain-shell$ wsh editconfig  # error
// after
$ export WAVETERM_TABID=<tab-id>
$ wsh editconfig
Defensive patterns

Strategy: validation

Validate before calling

tabId := os.Getenv("WAVETERM_TABID")
if tabId == "" {
    return errors.New("run inside a Wave terminal block or set WAVETERM_TABID")
}

Try / catch

if err := wsh.EditConfig(); err != nil {
    if strings.Contains(err.Error(), "WAVETERM_TABID") {
        // fall back to opening the config file with a local editor
    }
}

Prevention

When it happens

Trigger: Running `wsh editconfig` in a plain shell/SSH session, an environment where WAVETERM_TABID was cleared, or a non-interactive context spawned without the terminal's env.

Common situations: Using wsh over ssh into the same machine but from a non-Wave shell; running from cron/CI; Docker/container shells that don't inherit the terminal's environment.

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/c92887da57ae8971. Report an issue: GitHub.