{"record":{"id":"93ed6d2b60ca3f8a","repo":"zeroclaw-labs/zeroclaw","slug":"architecture-mismatch-downloaded-binary-is-bin","errorCode":null,"errorMessage":"architecture mismatch: downloaded binary is {bin} but this host is {host} — the release asset may be mispackaged","messagePattern":"architecture mismatch: downloaded binary is (.+?) but this host is (.+?) — the release asset may be mispackaged","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/commands/update.rs","lineNumber":757,"sourceCode":"    tokio::fs::File::open(path)\n        .await\n        .context(\"failed to open binary to read header\")?\n        .take(4096)\n        .read_to_end(&mut header)\n        .await\n        .context(\"failed to read binary header\")?;\n\n    if header.len() < 20 {\n        bail!(\"downloaded file too small to be a valid binary\");\n    }\n\n    let binary_arch = detect_arch_from_header(&header);\n    let host_arch = host_architecture();\n\n    if let (Some(bin), Some(host)) = (binary_arch, host_arch)\n        && bin != host\n    {\n        bail!(\n            \"architecture mismatch: downloaded binary is {bin} but this host is {host} — \\\n             the release asset may be mispackaged\"\n        );\n    }\n\n    Ok(())\n}\n\nfn detect_arch_from_header(header: &[u8]) -> Option<&'static str> {\n    // ELF magic: 0x7f 'E' 'L' 'F'\n    if header.len() >= 20 && header[0..4] == [0x7f, b'E', b'L', b'F'] {\n        // e_machine is at offset 18 (2 bytes, little-endian for LE binaries)\n        let e_machine = u16::from_le_bytes([header[18], header[19]]);\n        return match e_machine {\n            0x3E => Some(\"x86_64\"),\n            0xB7 => Some(\"aarch64\"),\n            0x03 => Some(\"x86\"),\n            0x28 => Some(\"arm\"),","sourceCodeStart":739,"sourceCodeEnd":775,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/src/commands/update.rs#L739-L775","documentation":"check_binary_arch compares the machine type detected from the staged binary's header (detect_arch_from_header) with the running host's architecture (host_architecture). When both are known and differ, the updater refuses to install a binary the host cannot execute, naming both architectures and flagging a possibly mispackaged release asset. If either side is unknown, the check is skipped.","triggerScenarios":"`zeroclaw update` when the selected release asset contains a binary for a different machine type than the host: x86_64 host receiving an aarch64 binary, Apple Silicon receiving an x86_64 asset, or a correctly-named asset packed with the wrong-arch binary inside.","commonSituations":"Asset-selection logic picking the wrong platform tuple (musl/gnu, darwin intel/arm64); running under Rosetta or an emulation layer where host identity is ambiguous; release packaging mixing up per-arch artifacts; manually forcing a platform override.","solutions":["Check the host architecture with `uname -m` (or `arch` on macOS) and confirm which asset the updater selected from the error text (it names both).","If the asset for your arch is mispackaged, report the release and pin the previous known-good version.","On Apple Silicon, verify the darwin-aarch64 asset is the one being downloaded rather than the x86_64 one.","If you drive asset selection yourself, map platform to asset explicitly instead of relying on defaults."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# pre-flight: match host arch to the asset you let the updater pick\nhost=\"$(uname -m)\"   # x86_64 / aarch64\ncase \"$host\" in\n  x86_64)  asset='zeroclaw-x86_64-*.tar.gz' ;;\n  aarch64) asset='zeroclaw-aarch64-*.tar.gz' ;;\n  *) echo \"unsupported host arch: $host\" >&2; exit 1 ;;\nesac","typeGuard":null,"tryCatchPattern":"match run_update().await {\n    Err(e) if e.to_string().starts_with(\"architecture mismatch\") => {\n        // wrong-arch asset: stop and correct platform selection; never force install\n    }\n    other => other,\n}","preventionTips":["Derive asset selection from `uname -m` plus OS, not from defaults, in automation that pins releases.","In release CI, parse each artifact's ELF/PE machine type and compare with its filename before publishing.","Remember Rosetta/translation layers: pick the native arch, not the emulated one."],"tags":["update","architecture","binary-validation","release-artifact","platform"],"backgroundTag":"wrong-architecture-binary","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}