zeroclaw-labs/zeroclaw · error

Failed to install arduino:avr core

Error message

Failed to install arduino:avr core

What it means

ensure_avr_core() checks `arduino-cli core list` for `arduino:avr`; if absent it runs `arduino-cli core install arduino:avr` and bails when that command exits non-zero. arduino-cli itself started fine, but the AVR core download/install step failed. Because the function uses `.status()`, the underlying arduino-cli error text is not captured in the message, so the CLI must be run manually to see the cause.

Source

Thrown at crates/zeroclaw-hardware/src/peripherals/arduino_flash.rs:88

/// Ensure arduino:avr core is installed.
fn ensure_avr_core() -> Result<()> {
    let out = Command::new("arduino-cli")
        .args(["core", "list"])
        .output()
        .context("arduino-cli core list failed")?;
    let stdout = String::from_utf8_lossy(&out.stdout);
    if stdout.contains("arduino:avr") {
        return Ok(());
    }

    println!("Installing Arduino AVR core...");
    let status = Command::new("arduino-cli")
        .args(["core", "install", "arduino:avr"])
        .status()
        .context("arduino-cli core install failed")?;
    if !status.success() {
        anyhow::bail!("Failed to install arduino:avr core");
    }
    println!("AVR core installed.");
    Ok(())
}

/// Flash ZeroClaw firmware to Arduino at the given port.
pub fn flash_arduino_firmware(port: &str) -> Result<()> {
    ensure_arduino_cli()?;
    ensure_avr_core()?;

    let temp_dir = std::env::temp_dir().join(format!("zeroclaw_flash_{}", uuid::Uuid::new_v4()));
    let sketch_dir = temp_dir.join(SKETCH_NAME);
    let ino_path = sketch_dir.join(format!("{}.ino", SKETCH_NAME));

    std::fs::create_dir_all(&sketch_dir).context("Failed to create sketch dir")?;
    std::fs::write(&ino_path, FIRMWARE_INO).context("Failed to write firmware")?;

    let sketch_path = sketch_dir.to_string_lossy();

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Run `arduino-cli core install arduino:avr` in a shell to see the real error output, then fix what it reports
  2. Run `arduino-cli core update-index` and retry the install
  3. Check network/proxy reachability of downloads.arduino.cc from the flashing machine
  4. If ~/.arduino15 is corrupt (partial downloads, index errors), remove it and let arduino-cli recreate it
  5. Upgrade arduino-cli (`arduino-cli version`) and retry the flash
Defensive patterns

Strategy: validation

Validate before calling

let out = std::process::Command::new("arduino-cli")
    .args(["core", "list"])
    .output()?;
if !String::from_utf8_lossy(&out.stdout).contains("arduino:avr") {
    // install with visible output before flashing
    std::process::Command::new("arduino-cli")
        .args(["core", "install", "arduino:avr"])
        .status()?;
}
flash_arduino_firmware(port)?;

Try / catch

match flash_arduino_firmware(port) {
    Err(e) if e.to_string().contains("Failed to install arduino:avr core") => {
        // environmental: message lacks stderr; run `arduino-cli core install arduino:avr`
        // manually to diagnose, then retry
    }
    rest => rest,
}

Prevention

When it happens

Trigger: flash_arduino_firmware(port) is called, `arduino-cli core list` output lacks `arduino:avr` (fresh arduino-cli install), and `arduino-cli core install arduino:avr` exits non-zero — typically no network access to downloads.arduino.cc, a corrupted ~/.arduino15 directory, or a proxy blocking the download.

Common situations: First flash on a machine with a freshly installed arduino-cli; corporate networks with TLS-inspecting proxies; an interrupted earlier install leaving partial files under ~/.arduino15; very old arduino-cli versions with stale board indexes.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/40002b3818ce067c. Report an issue: GitHub.