tonhowtf/omniget · error

PowerShell

Error message

PowerShell: {}

What it means

A PowerShell invocation launched with -NoProfile -NonInteractive -ExecutionPolicy Bypass exited with a non-zero status; the {} is PowerShell's trimmed stderr. It is the single failure path for every shell script used by list, remove, and restore, so the failing script determines the real cause (bad cmdlet output, missing app entry, execution policy overrides).

Solutions

  1. Inspect the PowerShell stderr in the message to see which part of the script failed
  2. Run the same script manually in PowerShell to reproduce and diagnose
  3. Ensure PowerShell is available and not blocked by group policy or antivirus
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src-tauri/omniget-core/src/core/tools/win_apps.rs:182 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/win_apps.rs:182

        .iter()
        .find(|(prefix, _)| name.starts_with(prefix))
        .map(|(_, label)| *label)
}

async fn powershell(script: &str) -> anyhow::Result<String> {
    let o = crate::core::process::command("powershell")
        .args([
            "-NoProfile",
            "-NonInteractive",
            "-ExecutionPolicy",
            "Bypass",
            "-Command",
            script,
        ])
        .output()
        .await?;
    if !o.status.success() {
        return Err(anyhow!(
            "PowerShell: {}",
            String::from_utf8_lossy(&o.stderr).trim()
        ));
    }
    Ok(String::from_utf8_lossy(&o.stdout).to_string())
}

pub async fn list() -> anyhow::Result<Vec<AppxPackage>> {
    if !cfg!(target_os = "windows") {
        return Ok(vec![]);
    }
    let out = powershell("Get-AppxPackage | Where-Object { -not $_.IsFramework -and -not $_.IsResourcePackage } | Select-Object Name,PackageFullName,Version,Publisher,NonRemovable | ConvertTo-Json -Compress").await?;
    let json: serde_json::Value =
        serde_json::from_str(out.trim()).unwrap_or(serde_json::Value::Null);
    let items: Vec<serde_json::Value> = match json {
        serde_json::Value::Array(a) => a,
        serde_json::Value::Object(_) => vec![json],
        _ => vec![],

View on GitHub (pinned to 8600b91f42)