jdx/mise · error

winget list failed for

Error message

winget list failed for '{}': {}

What it means

The winget backend runs `winget list` to determine a package's installed state without accepting agreements or changing winget state. When the command exits with a status mise does not recognize as a normal outcome, it bails with the package name plus whatever winget printed on stdout/stderr (joined, non-empty parts kept). This surfaces winget's own diagnostics — source errors, authentication, agreement prompts — instead of guessing the package state.

Solutions

  1. Run `winget list --id <package>` manually and read the detail text included in the error message to see winget's actual failure.
  2. Run `winget source reset --force` and `winget source update` to repair broken msstore/winget sources.
  3. Update winget (`winget upgrade Microsoft.AppInstaller` or via Store) — older builds return different exit codes.
  4. Accept agreements once interactively (`winget list` in a normal terminal) so non-interactive runs do not stall on prompts.
  5. Ensure the package is addressed by a stable id (use `--id`-compatible ids in mise config) to avoid ambiguous-match errors.
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight winget health and source availability before mise winget operations
import { execSync } from 'node:child_process';
function wingetReady() {
  try { execSync('winget --info', { stdio: 'ignore' }); }
  catch { throw new Error('winget unavailable — install App Installer / check PATH'); }
  try { execSync('winget source update --disable-interactivity', { stdio: 'ignore' }); }
  catch { console.warn('winget source update failed — run `winget source reset --force`'); }
}

Try / catch

try { await misePkgInstallWinget(pkg) } catch (e) { if (String(e).startsWith('winget list failed')) { const detail = e.message.split(': ').slice(1).join(': '); console.error('winget said:', detail); if (/agreement/i.test(detail)) acceptWingetAgreementsInteractively(); else if (/source/i.test(detail)) execSync('winget source reset --force'); } else throw e; }

Prevention

When it happens

Trigger: Calling `query_state` (via `query_package` or tests where other failures are propagated) when `winget list --id <name>` returns an unexpected exit code, e.g. winget not properly initialized, source unavailable, or the package id ambiguous/unknown in a way winget reports as an error rather than an empty list.

Common situations: winget's msstore source is broken or requires updated agreements; AppInstaller source reset needed; running in a non-interactive session where winget tries to prompt; winget not on PATH or an old winget version with different exit codes; corporate proxy blocking winget sources.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/1ebf40197269f738. Report an issue: GitHub.

Appendix: source

Thrown at src/system/packages/winget.rs:147

    match code {
        Some(0) => {
            let installed = parse_list_rows(stdout, &request.name);
            if installed.is_empty() {
                return Err(eyre::eyre!(
                    "winget list succeeded but returned no parseable row for '{}'",
                    request.name
                ));
            }
            Ok(package_state(request, &installed))
        }
        Some(NO_APPLICATIONS_FOUND) => Ok(PackageState::Missing),
        _ => {
            let detail = [stdout.trim(), stderr.trim()]
                .into_iter()
                .filter(|part| !part.is_empty())
                .collect::<Vec<_>>()
                .join("\n");
            bail!("winget list failed for '{}': {}", request.name, detail);
        }
    }
}

/// Queries one package without accepting agreements or changing WinGet state.
async fn query_package(request: &PackageRequest) -> Result<PackageStatus> {
    let args = list_args(request);
    debug!("$ winget {}", args.join(" "));
    let output = tokio::process::Command::new("winget")
        .args(args)
        .stdin(Stdio::null())
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
        .await?;
    let stdout = String::from_utf8_lossy(&output.stdout);
    let stderr = String::from_utf8_lossy(&output.stderr);
    let state = query_state(output.status.code(), &stdout, &stderr, request)?;

View on GitHub (pinned to 533346cc37)