nikivdev/code · error

Unsupported macOS architecture

Error message

Unsupported macOS architecture

What it means

Raised by `detect_release_target` when the binary runs on macOS but the CPU architecture is neither x86_64 nor aarch64, so no release artifact name can be produced. GitHub release targets only exist for darwin x86_64 and aarch64.

Source

Thrown at src/upgrade.rs:146

        elapsed_hours >= UPGRADE_CHECK_INTERVAL_HOURS
    }
}

/// Get current version from Cargo.toml embedded at compile time.
pub fn current_version() -> &'static str {
    env!("CARGO_PKG_VERSION")
}

/// Detect the current platform (os, arch).
fn detect_release_target() -> Result<&'static str> {
    if cfg!(target_os = "macos") {
        if cfg!(target_arch = "x86_64") {
            return Ok("x86_64-apple-darwin");
        }
        if cfg!(target_arch = "aarch64") {
            return Ok("aarch64-apple-darwin");
        }
        bail!("Unsupported macOS architecture");
    }
    if cfg!(target_os = "linux") {
        if cfg!(target_arch = "x86_64") {
            return Ok("x86_64-unknown-linux-gnu");
        }
        if cfg!(target_arch = "aarch64") {
            return Ok("aarch64-unknown-linux-gnu");
        }
        bail!("Unsupported Linux architecture");
    }

    bail!("Unsupported operating system for self-upgrade (only macOS/Linux supported)");
}

fn detect_legacy_platform() -> Result<(&'static str, &'static str)> {
    let os = if cfg!(target_os = "macos") {
        "darwin"
    } else if cfg!(target_os = "linux") {

View on GitHub (pinned to a747e741ae)

Solutions

  1. Use a binary built for x86_64-apple-darwin or aarch64-apple-darwin.
  2. Update the tool manually instead of self-upgrade (download the release asset directly from GitHub).
  3. Add a matching `cfg!(target_arch)` arm for your architecture and contribute/publish an artifact for it.
Defensive patterns

Strategy: fallback

Try / catch

match detect_release_target() {
    Ok(target) => { /* download target asset */ }
    Err(e) if e.to_string().contains("Unsupported macOS") => {
        eprintln!("no prebuilt asset for this Mac arch; update manually from GitHub releases");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Self-upgrade (`run`) on a Mac whose `cfg!(target_arch)` is not x86_64 or aarch64 at compile time — effectively exotic/older Mac hardware (PowerPC-era or experimental targets) or a cross-compiled build for an unusual architecture.

Common situations: Running a cross-compiled binary on unsupported hardware; using builds distributed for uncommon targets; very old hackintosh/VM configurations.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/80c5274d307f423d. Report an issue: GitHub.