{"record":{"id":"328de17011327556","repo":"matryer/xbar","slug":"run-in-terminal-script-failed-s","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_darwin.go","lineNumber":49,"sourceCode":"\t}{\n\t\tCommand: commandLine,\n\t\tVars:    fmt.Sprintf(\"%q\", variablesEnvString(vars)),\n\t\tParams:  paramsStr,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tappleScript := renderedScript.String()\n\tlog.Println(p.Command, \"RunInTerminal\", appleScript)\n\tcmd := exec.Command(\"osascript\", \"-s\", \"h\", \"-e\", appleScript)\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":31,"sourceCodeEnd":53,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/plugin_darwin.go#L31-L53","documentation":"On macOS, runInTerminal executes a helper shell script that opens a terminal running the plugin interactively. The command's stderr is captured, and run errors are intentionally ignored/logged; however if the script's process exit code is non-zero, this error is returned containing the script's stderr output.","triggerScenarios":"cmd.Run() completes but ProcessState.ExitCode() != 0 for the darwin terminal helper script — e.g. the terminal app can't be launched, the script can't find/open Terminal.app, or the inner command fails.","commonSituations":"No GUI session available (SSH, headless mac), terminal application missing or non-standard, security/permissions blocking app launch (Automation/TCC prompts denied).","solutions":["Read the stderr text embedded in the error — it names why the script failed","Verify a GUI terminal (Terminal.app) is available and you're in a graphical session","Grant Automation permissions so the helper can control/open the terminal app","Test the plugin command directly in a terminal to rule out command-specific failures"],"exampleFix":"// before\n// running RunInTerminal over SSH (no GUI) -> script exits non-zero\n// after\n// run from a logged-in GUI session, or invoke the plugin command directly","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := p.RunInTerminal(ctx); err != nil {\n    var termErr interface{ Error() string }\n    _ = termErr\n    log.Printf(\"RunInTerminal failed: %v\", err) // stderr text is inside the message\n    // fall back to running the command non-interactively\n}","preventionTips":["Only call RunInTerminal from a GUI session","Verify Terminal.app opens manually on the target machine","Grant Automation permissions for terminal launching"],"tags":["plugins","terminal","macos","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"}