{"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/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/winget.rs#L238-L274","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `winget` manually once in a terminal and accept the source agreement prompts","Run `winget source update` and `winget source agree` explicitly, then retry","Update App Installer / winget from the Microsoft Store and verify with `winget --version`","If running in CI, pre-accept agreements in an earlier step and ensure winget is on PATH"],"exampleFix":"// before (CI, failing non-interactively)\nmise install winget:some.package\n// after (setup step first)\nwinget source agree --accept-source-agreements\nwinget source update\nmise install winget:some.package","handlingStrategy":"try-catch","validationCode":"winget --version || echo 'winget missing or broken'","typeGuard":null,"tryCatchPattern":"match prepare_mutation().await {\n    Err(e) if e.to_string().contains(\"source agreement\") => {\n        // prompt user to run `winget source agree` interactively\n    }\n    Err(e) => return Err(e),\n    Ok(_) => {}\n}","preventionTips":["Accept winget source agreements during machine/CI setup before using mise winget packages","Keep App Installer (winget) up to date on Windows hosts","Verify `winget --version` works before package operations"],"tags":["winget","windows","package-manager","external-command"],"backgroundTag":"command-not-found","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}