{"record":{"id":"40002b3818ce067c","repo":"zeroclaw-labs/zeroclaw","slug":"failed-to-install-arduino-avr-core","errorCode":null,"errorMessage":"Failed to install arduino:avr core","messagePattern":"Failed to install arduino:avr core","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-hardware/src/peripherals/arduino_flash.rs","lineNumber":88,"sourceCode":"\n/// Ensure arduino:avr core is installed.\nfn ensure_avr_core() -> Result<()> {\n    let out = Command::new(\"arduino-cli\")\n        .args([\"core\", \"list\"])\n        .output()\n        .context(\"arduino-cli core list failed\")?;\n    let stdout = String::from_utf8_lossy(&out.stdout);\n    if stdout.contains(\"arduino:avr\") {\n        return Ok(());\n    }\n\n    println!(\"Installing Arduino AVR core...\");\n    let status = Command::new(\"arduino-cli\")\n        .args([\"core\", \"install\", \"arduino:avr\"])\n        .status()\n        .context(\"arduino-cli core install failed\")?;\n    if !status.success() {\n        anyhow::bail!(\"Failed to install arduino:avr core\");\n    }\n    println!(\"AVR core installed.\");\n    Ok(())\n}\n\n/// Flash ZeroClaw firmware to Arduino at the given port.\npub fn flash_arduino_firmware(port: &str) -> Result<()> {\n    ensure_arduino_cli()?;\n    ensure_avr_core()?;\n\n    let temp_dir = std::env::temp_dir().join(format!(\"zeroclaw_flash_{}\", uuid::Uuid::new_v4()));\n    let sketch_dir = temp_dir.join(SKETCH_NAME);\n    let ino_path = sketch_dir.join(format!(\"{}.ino\", SKETCH_NAME));\n\n    std::fs::create_dir_all(&sketch_dir).context(\"Failed to create sketch dir\")?;\n    std::fs::write(&ino_path, FIRMWARE_INO).context(\"Failed to write firmware\")?;\n\n    let sketch_path = sketch_dir.to_string_lossy();","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-hardware/src/peripherals/arduino_flash.rs#L70-L106","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `arduino-cli core install arduino:avr` in a shell to see the real error output, then fix what it reports","Run `arduino-cli core update-index` and retry the install","Check network/proxy reachability of downloads.arduino.cc from the flashing machine","If ~/.arduino15 is corrupt (partial downloads, index errors), remove it and let arduino-cli recreate it","Upgrade arduino-cli (`arduino-cli version`) and retry the flash"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let out = std::process::Command::new(\"arduino-cli\")\n    .args([\"core\", \"list\"])\n    .output()?;\nif !String::from_utf8_lossy(&out.stdout).contains(\"arduino:avr\") {\n    // install with visible output before flashing\n    std::process::Command::new(\"arduino-cli\")\n        .args([\"core\", \"install\", \"arduino:avr\"])\n        .status()?;\n}\nflash_arduino_firmware(port)?;","typeGuard":null,"tryCatchPattern":"match flash_arduino_firmware(port) {\n    Err(e) if e.to_string().contains(\"Failed to install arduino:avr core\") => {\n        // environmental: message lacks stderr; run `arduino-cli core install arduino:avr`\n        // manually to diagnose, then retry\n    }\n    rest => rest,\n}","preventionTips":["Pre-install the AVR core (`arduino-cli core install arduino:avr`) before the first flash","Run `arduino-cli core update-index` after installing or updating arduino-cli","Ensure network/proxy access to downloads.arduino.cc on flashing machines"],"tags":["arduino-cli","avr-core","hardware-flashing","subprocess-exit-code"],"backgroundTag":"package-install-failed","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}