tonhowtf/omniget · error

{}

Error message

{}

What it means

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.

Solutions

  1. Check that the app.path is correct and the bundle still exists before uninstalling
  2. Grant Automation/Apple Events permission to the host app in System Settings (Privacy & Security)
  3. Reproduce by running `osascript -e 'tell application "Finder" to delete POSIX file "<path>"'` manually to see the real error
  4. Improve the code to chain the original error context instead of discarding it: .map_err(|src| anyhow!(src))

Example fix

// before
.map_err(|_| anyhow!("{}", e))
// after
.map_err(|err| anyhow!("{}: {}", e, err))
Defensive patterns

Strategy: try-catch

Validate before calling

if cfg!(target_os = "macos") && !std::path::Path::new(&app.path).exists() {
    anyhow::bail!("app não existe mais: {}", app.path);
}

Try / catch

match uninstall::uninstall(&app).await {
    Err(e) if e.to_string().contains("osascript") => retry_with_fallback_delete(&app),
    Err(e) => log::error!("{}", e),
    Ok(msg) => log::info!("{}", msg),
}

Prevention

When it happens

Trigger: Calling uninstall(app) for a macOS application whose 'osascript -e tell application Finder to delete POSIX file ...' invocation fails.

Common situations: 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.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/07afd696a9db3302. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/uninstall.rs:650

    pub failed: Vec<String>,
}

/// Desinstala o app e, se pedido, manda as sobras para a lixeira.
pub async fn uninstall(app: &App, leftover_paths: &[String]) -> UninstallResult {
    let mut r = UninstallResult::default();
    let res: anyhow::Result<String> = if cfg!(target_os = "macos") {
        match trash::delete(&app.path) {
            Ok(_) => Ok("movido para a Lixeira".into()),
            Err(e) => {
                // Sem permissão: pede ao Finder (dialogo de senha do sistema)
                let script = format!(
                    "tell application \"Finder\" to delete POSIX file \"{}\"",
                    app.path.replace('"', "\\\"")
                );
                run("osascript", &["-e", &script])
                    .await
                    .map(|_| "movido para a Lixeira".into())
                    .map_err(|_| anyhow!("{}", e))
            }
        }
    } else if cfg!(target_os = "windows") {
        let cmd = app.key.trim();
        let lower = cmd.to_ascii_lowercase();
        if lower.contains("msiexec") {
            // MsiExec.exe /I{GUID} → /X{GUID} silencioso
            let guid = cmd
                .split(['{', '}'])
                .nth(1)
                .map(|g| format!("{{{}}}", g))
                .unwrap_or_default();
            if guid.is_empty() {
                Err(anyhow!("UninstallString sem GUID: {}", cmd))
            } else {
                run("msiexec", &["/x", &guid, "/passive", "/norestart"])
                    .await
                    .map(|_| "desinstalado".into())

View on GitHub (pinned to 8600b91f42)