{"record":{"id":"8f1203e8f810d434","repo":"matryer/xbar","slug":"run-in-terminal-script-failed-s-8f1203","errorCode":null,"errorMessage":"run in terminal script failed: %s","messagePattern":"run in terminal script failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/plugin_linux.go","lineNumber":33,"sourceCode":"\t}\n}\n\nfunc (p *Plugin) runInTerminal(appleScriptTemplate3, command, paramsStr string, vars []string) error {\n\n\tlog.Println(p.Command, \"RunInTerminal\", command)\n\t// x-terminal-emulator is provided by the 'alternatives' system\n\t// on most (all?) common Linux distributions, this is mapped to the default terminal application\n\tcmd := exec.Command(\"x-terminal-emulator\", \"-e\", command)\n\tcmd.Env = append(cmd.Env, vars...)\n\n\tvar stderr bytes.Buffer\n\tcmd.Stderr = &stderr\n\terr := cmd.Run()\n\tif err != nil {\n\t\tp.Debugf(\"(ignoring) RunInTerminal failed: %s\", err)\n\t}\n\tif cmd.ProcessState != nil && cmd.ProcessState.ExitCode() != 0 {\n\t\treturn errors.Errorf(\"run in terminal script failed: %s\", stderr.String())\n\t}\n\treturn nil\n}\n","sourceCodeStart":15,"sourceCodeEnd":37,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/plugin_linux.go#L15-L37","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the stderr in the error message for the exact failure reason","Install a supported terminal emulator (e.g. xterm) and ensure it's on PATH","Run in a session with DISPLAY (X11) or WAYLAND_DISPLAY set","Run the plugin command directly instead of via RunInTerminal"],"exampleFix":"// before\n// headless box: DISPLAY unset -> script exits non-zero\n// after\nexport DISPLAY=:0   // or run under a desktop session / use xvfb","handlingStrategy":"fallback","validationCode":"if os.Getenv(\"DISPLAY\") == \"\" && os.Getenv(\"WAYLAND_DISPLAY\") == \"\" {\n    return fmt.Errorf(\"no graphical session; skip RunInTerminal\")\n}\nif _, err := exec.LookPath(\"xterm\"); err != nil {\n    return fmt.Errorf(\"no terminal emulator installed\")\n}","typeGuard":null,"tryCatchPattern":"if err := p.runInTerminal(ctx); err != nil {\n    log.Printf(\"terminal open failed: %v\", err)\n    return runDirect(ctx) // fall back to non-interactive execution\n}","preventionTips":["Ensure DISPLAY/WAYLAND_DISPLAY is set in the session","Install a known terminal emulator (xterm is a safe baseline)","Check the emulator is on PATH, including snap/flatpak wrappers"],"tags":["plugins","terminal","linux","process"],"backgroundTag":"terminal-launch-script-failed","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}