{"record":{"id":"07afd696a9db3302","repo":"tonhowtf/omniget","slug":"uninstall","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/uninstall.rs","lineNumber":650,"sourceCode":"    pub failed: Vec<String>,\n}\n\n/// Desinstala o app e, se pedido, manda as sobras para a lixeira.\npub async fn uninstall(app: &App, leftover_paths: &[String]) -> UninstallResult {\n    let mut r = UninstallResult::default();\n    let res: anyhow::Result<String> = if cfg!(target_os = \"macos\") {\n        match trash::delete(&app.path) {\n            Ok(_) => Ok(\"movido para a Lixeira\".into()),\n            Err(e) => {\n                // Sem permissão: pede ao Finder (dialogo de senha do sistema)\n                let script = format!(\n                    \"tell application \\\"Finder\\\" to delete POSIX file \\\"{}\\\"\",\n                    app.path.replace('\"', \"\\\\\\\"\")\n                );\n                run(\"osascript\", &[\"-e\", &script])\n                    .await\n                    .map(|_| \"movido para a Lixeira\".into())\n                    .map_err(|_| anyhow!(\"{}\", e))\n            }\n        }\n    } else if cfg!(target_os = \"windows\") {\n        let cmd = app.key.trim();\n        let lower = cmd.to_ascii_lowercase();\n        if lower.contains(\"msiexec\") {\n            // MsiExec.exe /I{GUID} → /X{GUID} silencioso\n            let guid = cmd\n                .split(['{', '}'])\n                .nth(1)\n                .map(|g| format!(\"{{{}}}\", g))\n                .unwrap_or_default();\n            if guid.is_empty() {\n                Err(anyhow!(\"UninstallString sem GUID: {}\", cmd))\n            } else {\n                run(\"msiexec\", &[\"/x\", &guid, \"/passive\", \"/norestart\"])\n                    .await\n                    .map(|_| \"desinstalado\".into())","sourceCodeStart":632,"sourceCodeEnd":668,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/uninstall.rs#L632-L668","documentation":"On macOS, the uninstall flow builds an osascript AppleScript command to move the .app bundle to the Trash via Finder. If run(\"osascript\", ...) returns Err, the original error is discarded and replaced with the anyhow!(\"{}\", e) wrapper — e is the anyhow::Error from the failed run call. This masks the underlying osascript failure reason.","triggerScenarios":"Calling uninstall(app) for a macOS application whose 'osascript -e tell application Finder to delete POSIX file ...' invocation fails.","commonSituations":"App bundle path contains characters that break the AppleScript string despite escaping; Finder is not running or scripting is restricted; file no longer exists; automation permissions (TCC) denied for the host process.","solutions":["Check that the app.path is correct and the bundle still exists before uninstalling","Grant Automation/Apple Events permission to the host app in System Settings (Privacy & Security)","Reproduce by running `osascript -e 'tell application \"Finder\" to delete POSIX file \"<path>\"'` manually to see the real error","Improve the code to chain the original error context instead of discarding it: .map_err(|src| anyhow!(src))"],"exampleFix":"// before\n.map_err(|_| anyhow!(\"{}\", e))\n// after\n.map_err(|err| anyhow!(\"{}: {}\", e, err))","handlingStrategy":"try-catch","validationCode":"if cfg!(target_os = \"macos\") && !std::path::Path::new(&app.path).exists() {\n    anyhow::bail!(\"app não existe mais: {}\", app.path);\n}","typeGuard":null,"tryCatchPattern":"match uninstall::uninstall(&app).await {\n    Err(e) if e.to_string().contains(\"osascript\") => retry_with_fallback_delete(&app),\n    Err(e) => log::error!(\"{}\", e),\n    Ok(msg) => log::info!(\"{}\", msg),\n}","preventionTips":["Verify the .app path exists before attempting Trash deletion","Request Apple Events / Automation permission upfront on macOS","Handle the masked error by testing osascript manually when it fails"],"tags":["macos","applescript","uninstall","error-masking","rust"],"backgroundTag":"file-delete-failed","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"}