{"record":{"id":"d3a3f8de45c81006","repo":"jdx/mise","slug":"mas-upgrade-failed","errorCode":null,"errorMessage":"mas upgrade failed: {}","messagePattern":"mas upgrade failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/mas.rs","lineNumber":299,"sourceCode":"    async fn upgrade(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {\n        if let Some(p) = pkgs.iter().find(|p| !is_adam_id(&p.name)) {\n            bail!(\"mas upgrade requires a numeric ADAM ID ('{p}'); use `mas search` to find it\");\n        }\n        let mut args = vec![\"upgrade\".to_string()];\n        args.extend(pkgs.iter().map(|p| p.name.clone()));\n        if opts.dry_run {\n            miseprintln!(\"mas {}\", args.join(\" \"));\n            return Ok(());\n        }\n        debug!(\"$ mas {}\", args.join(\" \"));\n        let output = tokio::process::Command::new(self.bin().await?)\n            .args(&args)\n            .stdin(Stdio::null())\n            .output()\n            .await?;\n        if !output.status.success() {\n            let stderr = String::from_utf8_lossy(&output.stderr);\n            bail!(\"mas upgrade failed: {}\", stderr.trim());\n        }\n        Ok(())\n    }\n}\n\npub(crate) fn is_adam_id(name: &str) -> bool {\n    !name.is_empty() && name.chars().all(|c| c.is_ascii_digit())\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    fn req(name: &str, version: Option<&str>) -> PackageRequest {\n        PackageRequest {\n            name: name.to_string(),\n            version: version.map(str::to_string),\n            tap_url: None,","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/mas.rs#L281-L317","documentation":"upgrade() runs `mas upgrade <ids...>`; if the subprocess exits non-zero, the backend raises this error with mas's trimmed stderr as the detail. The actual failure reason (auth, connectivity, invalid ID) is whatever mas printed.","triggerScenarios":"Calling upgrade() with valid ADAM IDs where `mas upgrade` fails: not signed in, network error, App Store daemon issues, or an ID with no pending/available update that mas treats as an error.","commonSituations":"Automated update runs on a machine whose App Store session expired; offline machines; apps requiring newer macOS than installed.","solutions":["Inspect the stderr detail after the prefix and fix mas's underlying complaint (usually sign-in or network).","Confirm sign-in with `mas account` and retry, or update via the App Store app.","Run `mas upgrade <id>` manually to reproduce and see full mas diagnostics; also check macOS version requirements for the app."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let acct = Command::new(\"mas\").arg(\"account\").output()?;\nif !acct.status.success() { /* re-authenticate before upgrading */ }","typeGuard":null,"tryCatchPattern":"if let Err(e) = backend.upgrade(&pkgs, &opts).await {\n    if e.to_string().starts_with(\"mas upgrade failed:\") { eprintln!(\"{}\", e); /* check sign-in/network, then retry */ }\n    else { return Err(e.into()); }\n}","preventionTips":["Keep the App Store session alive on machines running automated upgrades.","Retry upgrades when offline; mas needs Apple servers.","Run `mas outdated` first to confirm which apps actually have updates."],"tags":["mas","subprocess","upgrade","command-failed"],"backgroundTag":"command-failed","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"}