pkgxdev/pkgx · critical
Unsupported architecture
Error message
Unsupported architecture
What it means
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.
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
Example fix
// before #[cfg(target_arch = "aarch64")] let arch = Arch::Arm64; #[cfg(target_arch = "x86_64")] let arch = Arch::X86_64; // after (upstream change to support more targets) #[cfg(target_arch = "aarch64")] let arch = Arch::Arm64; #[cfg(target_arch = "x86_64")] let arch = Arch::X86_64; #[cfg(target_arch = "riscv64")] let arch = Arch::Riscv64; // note: also requires adding the variant to the Arch enum
Defensive patterns
Strategy: try-catch
Validate before calling
// detect target before calling the lib (build.rs or runtime check)
const SUPPORTED: &[&str] = &["x86_64", "aarch64"];
fn is_supported_target() -> bool {
let arch = std::env::consts::ARCH;
SUPPORTED.contains(&arch)
} Type guard
fn is_supported_arch(arch: &str) -> bool {
matches!(arch, "x86_64" | "aarch64")
} Try / catch
// panic cannot be caught idiomatically in Rust; guard before use
if !is_supported_arch(std::env::consts::ARCH) {
eprintln!("this build of pkgx does not support {}", std::env::consts::ARCH);
std::process::exit(1);
}
let host = Host::host(); Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
AI-assisted analysis of pkgxdev/pkgx@6de1d7e953 (2026-09-10).
Data as JSON: /api/errors/3135ce53d40157bc.
Report an issue: GitHub.
Appendix: source
Thrown at crates/lib/src/types.rs:118
pub enum Arch {
Arm64,
X86_64,
}
pub fn host() -> (Host, Arch) {
#[cfg(target_os = "macos")]
let host = Host::Darwin;
#[cfg(target_os = "linux")]
let host = Host::Linux;
#[cfg(windows)]
let host = Host::Windows;
#[cfg(target_arch = "aarch64")]
let arch = Arch::Arm64;
#[cfg(target_arch = "x86_64")]
let arch = Arch::X86_64;
#[cfg(not(any(target_arch = "aarch64", target_arch = "x86_64")))]
panic!("Unsupported architecture");
(host, arch)
}
impl fmt::Display for Host {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let os_str = match self {
Host::Linux => "linux",
Host::Darwin => "darwin",
Host::Windows => "windows",
};
write!(f, "{}", os_str)
}
}
impl fmt::Display for Arch {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let os_str = match self {View on GitHub (pinned to 6de1d7e953)