{"record":{"id":"3c0436b1bdb515b4","repo":"tonhowtf/omniget","slug":"falhou","errorCode":null,"errorMessage":"{} falhou: {}","messagePattern":"(.+?) falhou: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/startup.rs","lineNumber":36,"sourceCode":"    pub source: String,\n    /// \"user\" | \"system\"\n    pub scope: String,\n    pub path: String,\n    pub enabled: bool,\n    pub can_toggle: bool,\n}\n\nfn home() -> PathBuf {\n    dirs::home_dir().unwrap_or_default()\n}\n\nasync fn run(program: &str, args: &[&str]) -> anyhow::Result<String> {\n    let o = crate::core::process::command(program)\n        .args(args)\n        .output()\n        .await?;\n    if !o.status.success() {\n        return Err(anyhow!(\n            \"{} falhou: {}\",\n            program,\n            String::from_utf8_lossy(&o.stderr).trim()\n        ));\n    }\n    Ok(String::from_utf8_lossy(&o.stdout).to_string())\n}\n\n// ── macOS ──────────────────────────────────────────────────────────────\n\nasync fn plist_json(path: &Path) -> Option<serde_json::Value> {\n    let o = crate::core::process::command(\"plutil\")\n        .args([\"-convert\", \"json\", \"-o\", \"-\"])\n        .arg(path)\n        .output()\n        .await\n        .ok()?;\n    if !o.status.success() {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/startup.rs#L18-L54","documentation":"This generic helper in startup.rs runs an external command (osascript on macOS, gsettings/systemctl etc. on Linux) and fails with \"<program> falhou: <stderr>\" when the process exits with a non-zero status. The command's stderr is trimmed and embedded in the message. It is the single choke point through which all login-items operations (mac_items, mac_set, linux_items, linux_set) report subprocess failures.","triggerScenarios":"Any startup-items operation where the spawned process exits non-zero: osascript lacks Automation/Accessibility permission to control System Events, the binary does not exist or is not on PATH, gsettings fails because DBUS_SESSION_BUS_ADDRESS is unset (e.g. running outside the user session), or the requested login item does not exist for a remove query.","commonSituations":"macOS Tauri app not granted 'Automation' permission for System Events so osascript returns error 1002 or -1743; running the app from SSH/cron with no D-Bus session on Linux; missing osascript/gsettings binaries in a minimal container; AppleScript syntax rejected due to an item name containing quotes.","solutions":["Read the stderr text embedded in the error message; it names the underlying cause (permission denied, command not found, no such item)","On macOS, grant the app Automation permission for System Events in System Settings > Privacy & Security > Automation (or re-sign with proper entitlements)","On Linux, ensure the app runs inside the user's graphical session with D-Bus available (DBUS_SESSION_BUS_ADDRESS set)","Verify the required binaries (osascript, gsettings, systemctl) exist and are on PATH for the environment running the app","Quote/escape item names passed into AppleScript and confirm the login item actually exists before removing it"],"exampleFix":"// before: opaque failure when binary is missing or stderr is empty\nlet o = crate::core::process::command(program).args(args).output().await?;\nif !o.status.success() {\n    return Err(anyhow!(\"{} falhou: {}\", program, String::from_utf8_lossy(&o.stderr).trim()));\n}\n// after: distinguish spawn failure from non-zero exit\nlet o = crate::core::process::command(program).args(args).output().await\n    .with_context(|| format!(\"nao foi possivel executar '{}'\", program))?;\nif !o.status.success() {\n    let err = String::from_utf8_lossy(&o.stderr).trim();\n    let out = String::from_utf8_lossy(&o.stdout).trim();\n    return Err(anyhow!(\"{} falhou ({}): {}{}\", program, o.status, err,\n        if err.is_empty() { out } else { \"\" }));\n}","handlingStrategy":"try-catch","validationCode":"// Verify the external tool is available before using it\nasync fn tool_available(program: &str) -> bool {\n    crate::core::process::command(program).arg(\"--help\")\n        .output().await.map(|o| o.status.success()).unwrap_or(false)\n}\nif !tool_available(\"osascript\").await { return Err(anyhow!(\"osascript indisponivel neste ambiente\")); }","typeGuard":"fn has_usable_stderr(o: &std::process::Output) -> bool {\n    !String::from_utf8_lossy(&o.stderr).trim().is_empty()\n}","tryCatchPattern":"match set_enabled(item, true).await {\n    Ok(_) => {},\n    Err(e) if e.to_string().contains(\"osascript falhou\") => {\n        eprintln!(\"Conceda permissao de Automacao (System Events) ao app: {e}\");\n    }\n    Err(e) if e.to_string().contains(\"gsettings falhou\") => {\n        eprintln!(\"Execute dentro de uma sessao grafica com D-Bus: {e}\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Grant macOS Automation permission for System Events on first launch (and ship entitlements)","Run Linux startup-item operations inside the user's graphical session with D-Bus present","Check tool availability on PATH at app startup and degrade gracefully","Include both stderr and exit status in subprocess errors for diagnosability"],"tags":["process","subprocess","rust","macos","linux"],"backgroundTag":"command-not-found","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}