jdx/mise · error
winget {action} failed with {status}
Error message
winget {action} failed with {status} What it means
run_winget executes a winget action (e.g. source refresh via refresh, or per-package install/upgrade/uninstall via run_packages) with output inherited, and checks the resulting exit status against accepted exit codes. If the status isn't accepted, this error reports the action and status. Certain winget non-zero codes (like reboot-required) can be pre-accepted via accepted_exit_codes.
Source
Thrown at src/system/packages/winget.rs:188
}
/// Returns whether an exit code is successful for the current operation.
fn command_succeeded(code: Option<i32>, accepted_exit_codes: &[i32]) -> bool {
code == Some(0) || code.is_some_and(|code| accepted_exit_codes.contains(&code))
}
/// Runs WinGet and accepts only zero plus explicitly allowed no-op codes.
async fn run_winget(args: &[String], action: &str, accepted_exit_codes: &[i32]) -> Result<()> {
debug!("$ winget {}", args.join(" "));
let status = tokio::process::Command::new("winget")
.args(args)
.stdin(Stdio::null())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status()
.await?;
if !command_succeeded(status.code(), accepted_exit_codes) {
bail!("winget {action} failed with {status}");
}
Ok(())
}
/// Applies a WinGet command to each requested package in order.
async fn run_packages(
command: &str,
pkgs: &[PackageRequest],
dry_run: bool,
accepted_exit_codes: &[i32],
) -> Result<()> {
for pkg in pkgs {
let args = package_args(command, pkg);
if dry_run {
miseprintln!("winget {}", args.join(" "));
} else {
run_winget(
&args,View on GitHub (pinned to afd2eddd3a)
Solutions
- Run the same winget command manually to see the interactive output and exact failure reason
- If the failing code is benign (e.g. reboot required), update the accepted_exit_codes list for that action
- Elevate the shell (admin) if the failure is access-denied during install
- Run `winget source update` and retry if the failure was a source/network issue
Example fix
// before mise packages install winget:Git.Git # winget install failed with exit code 1978335189 (requires elevation) // after: run terminal as administrator mise packages install winget:Git.Git
Defensive patterns
Strategy: try-catch
Validate before calling
let probe = Command::new("winget").args(["--info"]).status()?;
if !probe.success() { /* winget broken or needs elevation */ } Type guard
fn winget_action_ok(status: ExitStatus, accepted: &[i32]) -> bool {
status.success() || accepted.contains(&status.code().unwrap_or(-1))
} Try / catch
match run_packages(&pkgs, "install").await {
Err(e) if e.to_string().contains("failed with") => {
if requires_elevation(&e) { rerun_elevated().await } else { return Err(e) }
}
other => other,
} Prevention
- Run package installs from an elevated shell when installers require admin rights
- Pre-list accepted benign exit codes (e.g. reboot-required) for winget actions
- Keep winget sources updated so downloads don't fail mid-install
When it happens
Trigger: Calling refresh or run_packages when a winget command (install/upgrade/uninstall/source update) exits with a failing code not in accepted_exit_codes — e.g. installer failure, hash mismatch, requires-elevation, or network error during download.
Common situations: winget install needs administrator rights (run from non-elevated shell); download failed or source unreachable; package installer returned its own error code; reboot-required exit codes not included in accepted_exit_codes.
Related errors
- winget list failed for '{}': {}
- bootstrap from repository failed with {status}
- exited with non-zero status: {status}
- {display_program} {display_args} failed: exit code {} {}
- {program} {display_args} failed: exit code {} {}
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/a8ac52d7b507e7a4.
Report an issue: GitHub.