jdx/mise · error

winget source agreement preparation failed with

Error message

winget source agreement preparation failed with {output}

What it means

Before mutating packages, winget must accept source agreements; prepare_mutation runs a hidden winget command with stdout suppressed to pre-accept them. If the exit code is not success and not NO_APPLICATIONS_FOUND, this bail fires, meaning the agreement pre-acceptance step failed.

Solutions

  1. Run `winget` once interactively and accept the source agreements manually, then retry.
  2. Run `winget source update` (or `winget source reset --force`) to repair source state.
  3. Update App Installer / winget via the Microsoft Store on the host.
  4. Rerun from an elevated shell if msstore source access is blocked by policy.

Example fix

// before (non-interactive, agreements never accepted)
machine = fresh windows vm
// after
$ winget --accept-source-agreements
$ <retry operation>
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-accept agreements before automation
const probe = spawnSync('winget', ['source', 'update', '--accept-source-agreements']);
if (probe.status !== 0) throw new Error('winget source agreements could not be prepared');

Try / catch

try {
  await prepareMutation();
} catch (e) {
  console.error('Run `winget` once interactively to accept source agreements, then retry.');
  throw e;
}

Prevention

When it happens

Trigger: prepare_mutation runs `winget` (source agreement flow) with Stdio::null() stdout; command_succeeded(output.code(), &[NO_APPLICATIONS_FOUND]) is false — winget exited with an unexpected code, e.g. agreement could not be accepted or winget itself errored before any package work started.

Common situations: First-ever winget use on a machine where interactive agreement hasn't been accepted and automation can't prompt; corrupted or missing winget source; winget (App Installer) outdated on the host; running in a context where msstore source is inaccessible.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


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

Appendix: 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 533346cc37)