jdx/mise · error

winget source agreement preparation failed with {output}

Error message

winget source agreement preparation failed with {output}

What it means

This error is thrown by `prepare_mutation` in the winget package backend when the winget source agreement command exits with a code that winget does not consider success (and is not NO_APPLICATIONS_FOUND). mise must accept winget's source agreement non-interactively before installing/updating packages; if that preparation step fails, no package mutation is attempted. The output of the winget command is embedded in the message for diagnosis.

Source

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

        }
        Ok(statuses)
    }

    async fn prepare_mutation(&self, pkgs: &[PackageRequest]) -> Result<()> {
        let Some(pkg) = pkgs.first() else {
            return Ok(());
        };
        let args = accept_source_agreements_args(pkg);
        debug!("$ winget {}", args.join(" "));
        let output = tokio::process::Command::new("winget")
            .args(args)
            .stdin(Stdio::null())
            .stdout(Stdio::null())
            .stderr(Stdio::inherit())
            .status()
            .await?;
        if !command_succeeded(output.code(), &[NO_APPLICATIONS_FOUND]) {
            bail!("winget source agreement preparation failed with {output}");
        }
        Ok(())
    }

    async fn install(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {
        if opts.update && !pkgs.is_empty() {
            self.refresh(opts.dry_run).await?;
        }
        run_packages("install", pkgs, opts.dry_run, &[]).await
    }

    async fn upgrade(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {
        if !pkgs.is_empty() {
            self.refresh(opts.dry_run).await?;
        }
        run_packages("upgrade", pkgs, opts.dry_run, &[UPDATE_NOT_APPLICABLE]).await
    }
}

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Run `winget` manually once in a terminal and accept the source agreement prompts
  2. Run `winget source update` and `winget source agree` explicitly, then retry
  3. Update App Installer / winget from the Microsoft Store and verify with `winget --version`
  4. If running in CI, pre-accept agreements in an earlier step and ensure winget is on PATH

Example fix

// before (CI, failing non-interactively)
mise install winget:some.package
// after (setup step first)
winget source agree --accept-source-agreements
winget source update
mise install winget:some.package
Defensive patterns

Strategy: try-catch

Validate before calling

winget --version || echo 'winget missing or broken'

Try / catch

match prepare_mutation().await {
    Err(e) if e.to_string().contains("source agreement") => {
        // prompt user to run `winget source agree` interactively
    }
    Err(e) => return Err(e),
    Ok(_) => {}
}

Prevention

When it happens

Trigger: Calling install/update on the winget backend when `winget source agree` (or equivalent agreement acceptance command) exits with an unexpected status code — e.g. winget not installed, winget source not initialized, App Installer out of date, or agreement prompts blocked because stdin/stdout are nulled.

Common situations: Fresh Windows machines or CI runners where winget has never been run interactively; winget missing or broken on the PATH; msstore source agreement pending; running in a non-interactive service context where winget cannot prompt.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/97d1bf4fd2a51f24. Report an issue: GitHub.