matryer/xbar · error

run in terminal script failed: %s

Error message

run in terminal script failed: %s

What it means

On Linux, runInTerminal runs a helper script that opens the plugin in a terminal emulator. Run errors are logged and ignored, but if the script process exits with a non-zero code, this error is returned with the script's captured stderr.

Source

Thrown at pkg/plugins/plugin_linux.go:33

	}
}

func (p *Plugin) runInTerminal(appleScriptTemplate3, command, paramsStr string, vars []string) error {

	log.Println(p.Command, "RunInTerminal", command)
	// x-terminal-emulator is provided by the 'alternatives' system
	// on most (all?) common Linux distributions, this is mapped to the default terminal application
	cmd := exec.Command("x-terminal-emulator", "-e", command)
	cmd.Env = append(cmd.Env, vars...)

	var stderr bytes.Buffer
	cmd.Stderr = &stderr
	err := cmd.Run()
	if err != nil {
		p.Debugf("(ignoring) RunInTerminal failed: %s", err)
	}
	if cmd.ProcessState != nil && cmd.ProcessState.ExitCode() != 0 {
		return errors.Errorf("run in terminal script failed: %s", stderr.String())
	}
	return nil
}

View on GitHub (pinned to d624239058)

Solutions

  1. Check the stderr in the error message for the exact failure reason
  2. Install a supported terminal emulator (e.g. xterm) and ensure it's on PATH
  3. Run in a session with DISPLAY (X11) or WAYLAND_DISPLAY set
  4. Run the plugin command directly instead of via RunInTerminal

Example fix

// before
// headless box: DISPLAY unset -> script exits non-zero
// after
export DISPLAY=:0   // or run under a desktop session / use xvfb
Defensive patterns

Strategy: fallback

Validate before calling

if os.Getenv("DISPLAY") == "" && os.Getenv("WAYLAND_DISPLAY") == "" {
    return fmt.Errorf("no graphical session; skip RunInTerminal")
}
if _, err := exec.LookPath("xterm"); err != nil {
    return fmt.Errorf("no terminal emulator installed")
}

Try / catch

if err := p.runInTerminal(ctx); err != nil {
    log.Printf("terminal open failed: %v", err)
    return runDirect(ctx) // fall back to non-interactive execution
}

Prevention

When it happens

Trigger: cmd.Run() finishes and ProcessState.ExitCode() != 0 — commonly because no terminal emulator binary (xterm, gnome-terminal, etc.) is found by the script, DISPLAY/WAYLAND_DISPLAY is unset, or the chosen terminal fails to start.

Common situations: Headless servers or SSH sessions without X/Wayland; minimal installs lacking any terminal emulator; terminal emulator name not in the script's candidate list; snap/flatpak-sandboxed terminals not on PATH.

Related errors


AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02). Data as JSON: /api/errors/8f1203e8f810d434. Report an issue: GitHub.