{"record":{"id":"1ebf40197269f738","repo":"jdx/mise","slug":"winget-list-failed-for","errorCode":null,"errorMessage":"winget list failed for '{}': {}","messagePattern":"winget list failed for '(.+?)': (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/winget.rs","lineNumber":147,"sourceCode":"    match code {\n        Some(0) => {\n            let installed = parse_list_rows(stdout, &request.name);\n            if installed.is_empty() {\n                return Err(eyre::eyre!(\n                    \"winget list succeeded but returned no parseable row for '{}'\",\n                    request.name\n                ));\n            }\n            Ok(package_state(request, &installed))\n        }\n        Some(NO_APPLICATIONS_FOUND) => Ok(PackageState::Missing),\n        _ => {\n            let detail = [stdout.trim(), stderr.trim()]\n                .into_iter()\n                .filter(|part| !part.is_empty())\n                .collect::<Vec<_>>()\n                .join(\"\\n\");\n            bail!(\"winget list failed for '{}': {}\", request.name, detail);\n        }\n    }\n}\n\n/// Queries one package without accepting agreements or changing WinGet state.\nasync fn query_package(request: &PackageRequest) -> Result<PackageStatus> {\n    let args = list_args(request);\n    debug!(\"$ winget {}\", args.join(\" \"));\n    let output = tokio::process::Command::new(\"winget\")\n        .args(args)\n        .stdin(Stdio::null())\n        .stdout(Stdio::piped())\n        .stderr(Stdio::piped())\n        .output()\n        .await?;\n    let stdout = String::from_utf8_lossy(&output.stdout);\n    let stderr = String::from_utf8_lossy(&output.stderr);\n    let state = query_state(output.status.code(), &stdout, &stderr, request)?;","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/winget.rs#L129-L165","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `winget list --id <package>` manually and read the detail text included in the error message to see winget's actual failure.","Run `winget source reset --force` and `winget source update` to repair broken msstore/winget sources.","Update winget (`winget upgrade Microsoft.AppInstaller` or via Store) — older builds return different exit codes.","Accept agreements once interactively (`winget list` in a normal terminal) so non-interactive runs do not stall on prompts.","Ensure the package is addressed by a stable id (use `--id`-compatible ids in mise config) to avoid ambiguous-match errors."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-flight winget health and source availability before mise winget operations\nimport { execSync } from 'node:child_process';\nfunction wingetReady() {\n  try { execSync('winget --info', { stdio: 'ignore' }); }\n  catch { throw new Error('winget unavailable — install App Installer / check PATH'); }\n  try { execSync('winget source update --disable-interactivity', { stdio: 'ignore' }); }\n  catch { console.warn('winget source update failed — run `winget source reset --force`'); }\n}","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Accept winget agreements once in an interactive terminal so non-interactive mise runs do not fail.","Keep winget (App Installer) updated; old builds return unrecognized exit codes.","Run `winget source reset --force` and `winget source update` periodically, especially in CI images.","Use exact, unambiguous package ids in mise config so `winget list --id` matches one package."],"tags":["winget","package-manager","external-command","windows"],"backgroundTag":"winget-list-failed","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}