{"record":{"id":"3135ce53d40157bc","repo":"pkgxdev/pkgx","slug":"unsupported-architecture","errorCode":null,"errorMessage":"Unsupported architecture","messagePattern":"Unsupported architecture","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/lib/src/types.rs","lineNumber":118,"sourceCode":"pub enum Arch {\n    Arm64,\n    X86_64,\n}\n\npub fn host() -> (Host, Arch) {\n    #[cfg(target_os = \"macos\")]\n    let host = Host::Darwin;\n    #[cfg(target_os = \"linux\")]\n    let host = Host::Linux;\n    #[cfg(windows)]\n    let host = Host::Windows;\n\n    #[cfg(target_arch = \"aarch64\")]\n    let arch = Arch::Arm64;\n    #[cfg(target_arch = \"x86_64\")]\n    let arch = Arch::X86_64;\n    #[cfg(not(any(target_arch = \"aarch64\", target_arch = \"x86_64\")))]\n    panic!(\"Unsupported architecture\");\n\n    (host, arch)\n}\n\nimpl fmt::Display for Host {\n    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n        let os_str = match self {\n            Host::Linux => \"linux\",\n            Host::Darwin => \"darwin\",\n            Host::Windows => \"windows\",\n        };\n        write!(f, \"{}\", os_str)\n    }\n}\n\nimpl fmt::Display for Arch {\n    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n        let os_str = match self {","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/pkgxdev/pkgx/blob/6de1d7e953b98061f69db95d4bd45a2a6ee5d7da/crates/lib/src/types.rs#L100-L136","documentation":"The `host()` function in types.rs only maps `target_arch = \"aarch64\"` to `Arch::Arm64` and `target_arch = \"x86_64\"` to `Arch::X86_64` via conditional compilation. On any other CPU architecture the cfg blocks compile nothing and a `panic!(\"Unsupported architecture\")` fires at runtime when `host()` is first called. This is a deliberate hard stop: the library cannot select or resolve packages for architectures it has no `Arch` variant for.","triggerScenarios":"Calling `Host::host()` (via the public `ls` or `get_url` paths) on a build compiled for any target other than aarch64 or x86_64 — e.g. armv7, riscv64, i686, powerpc. The panic happens immediately at the first call, before any package logic runs.","commonSituations":"Cross-compiling pkgx to a Raspberry Pi (armv7l) or other SBC, running in an emulator/QEMU setup with an unusual target triple, building for 32-bit x86 (i686) containers, or embedding the lib in firmware on niche architectures.","solutions":["Rebuild pkgx for an aarch64 or x86_64 target (e.g. `cargo build --target x86_64-unknown-linux-gnu`)","Use a machine/container image matching a supported architecture instead of cross-compiling","Add the missing architecture mapping in crates/lib/src/types.rs (new `#[cfg(target_arch = ...)] let arch = Arch::...;` plus a corresponding `Arch` variant) and upstream it","Check `rustc -vV | grep host` to confirm what target the binary was compiled for"],"exampleFix":"// before\n#[cfg(target_arch = \"aarch64\")]\nlet arch = Arch::Arm64;\n#[cfg(target_arch = \"x86_64\")]\nlet arch = Arch::X86_64;\n// after (upstream change to support more targets)\n#[cfg(target_arch = \"aarch64\")]\nlet arch = Arch::Arm64;\n#[cfg(target_arch = \"x86_64\")]\nlet arch = Arch::X86_64;\n#[cfg(target_arch = \"riscv64\")]\nlet arch = Arch::Riscv64;\n// note: also requires adding the variant to the Arch enum","handlingStrategy":"try-catch","validationCode":"// detect target before calling the lib (build.rs or runtime check)\nconst SUPPORTED: &[&str] = &[\"x86_64\", \"aarch64\"];\nfn is_supported_target() -> bool {\n    let arch = std::env::consts::ARCH;\n    SUPPORTED.contains(&arch)\n}","typeGuard":"fn is_supported_arch(arch: &str) -> bool {\n    matches!(arch, \"x86_64\" | \"aarch64\")\n}","tryCatchPattern":"// panic cannot be caught idiomatically in Rust; guard before use\nif !is_supported_arch(std::env::consts::ARCH) {\n    eprintln!(\"this build of pkgx does not support {}\", std::env::consts::ARCH);\n    std::process::exit(1);\n}\nlet host = Host::host();","preventionTips":["Pin build targets to x86_64 or aarch64 in CI matrices","Check `rustc -vV` host triple before deploying to devices","If you need other arches, add the cfg mapping and Arch variant upstream early","Avoid cross-compiling to unsupported triples without testing host() first"],"tags":["platform","architecture","compile-time","panic"],"backgroundTag":"unsupported-platform","analyzedSha":"6de1d7e953b98061f69db95d4bd45a2a6ee5d7da","analyzedAt":"2026-09-10T09:59:03.886Z","contentChangedAt":"2026-09-10T09:59:03.886Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}