{"record":{"id":"97d1bf4fd2a51f24","repo":"jdx/mise","slug":"winget-source-agreement-preparation-failed-with-o","errorCode":null,"errorMessage":"winget source agreement preparation failed with {output}","messagePattern":"winget source agreement preparation failed with (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/winget.rs","lineNumber":256,"sourceCode":"        }\n        Ok(statuses)\n    }\n\n    async fn prepare_mutation(&self, pkgs: &[PackageRequest]) -> Result<()> {\n        let Some(pkg) = pkgs.first() else {\n            return Ok(());\n        };\n        let args = accept_source_agreements_args(pkg);\n        debug!(\"$ winget {}\", args.join(\" \"));\n        let output = tokio::process::Command::new(\"winget\")\n            .args(args)\n            .stdin(Stdio::null())\n            .stdout(Stdio::null())\n            .stderr(Stdio::inherit())\n            .status()\n            .await?;\n        if !command_succeeded(output.code(), &[NO_APPLICATIONS_FOUND]) {\n            bail!(\"winget source agreement preparation failed with {output}\");\n        }\n        Ok(())\n    }\n\n    async fn install(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {\n        if opts.update && !pkgs.is_empty() {\n            self.refresh(opts.dry_run).await?;\n        }\n        run_packages(\"install\", pkgs, opts.dry_run, &[]).await\n    }\n\n    async fn upgrade(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {\n        if !pkgs.is_empty() {\n            self.refresh(opts.dry_run).await?;\n        }\n        run_packages(\"upgrade\", pkgs, opts.dry_run, &[UPDATE_NOT_APPLICABLE]).await\n    }\n}","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/winget.rs#L238-L274","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `winget` once interactively and accept the source agreements manually, then retry.","Run `winget source update` (or `winget source reset --force`) to repair source state.","Update App Installer / winget via the Microsoft Store on the host.","Rerun from an elevated shell if msstore source access is blocked by policy."],"exampleFix":"// before (non-interactive, agreements never accepted)\nmachine = fresh windows vm\n// after\n$ winget --accept-source-agreements\n$ <retry operation>","handlingStrategy":"try-catch","validationCode":"// Pre-accept agreements before automation\nconst probe = spawnSync('winget', ['source', 'update', '--accept-source-agreements']);\nif (probe.status !== 0) throw new Error('winget source agreements could not be prepared');","typeGuard":null,"tryCatchPattern":"try {\n  await prepareMutation();\n} catch (e) {\n  console.error('Run `winget` once interactively to accept source agreements, then retry.');\n  throw e;\n}","preventionTips":["Accept agreements once per machine before scripted use: `winget --accept-source-agreements`.","Keep App Installer (winget) updated on hosts used for automation.","Repair sources with `winget source reset --force` if agreement prep keeps failing."],"tags":["windows","winget","package-manager","external-command"],"backgroundTag":"http-error-response","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"}