Skip to content

CARGO_BUILD_TARGET is not used for cargo-espflash #1024

@diekleinekuh

Description

@diekleinekuh

Bug description

The CARGO_BUILD_TARGET environment variable is not used by cargo-espflash. It requires the --target command line parameter to be set.

  • I have searched the existing issues (closed & open) to make sure the issue hasn't already been reported
  • Check this box if you would like to work on a fix

To Reproduce

Steps to reproduce the behavior:

  1. Use a riscv esp32 chip like esp32c6 connected via usb
  2. Do CARGO_BUILD_TARGET=riscv32imac-esp-espidf cargo espflash flash
  3. Observe the output
[2026-04-03T13:34:07Z INFO ] Serial port: '/dev/ttyACM0'
[2026-04-03T13:34:07Z INFO ] Connecting...
[2026-04-03T13:34:07Z INFO ] Using flash stub
Error: cargo_espflash::no_target

  × Failed to build project
  ╰─▶ No target specified in cargo configuration
  help: Specify the target in `.cargo/config.toml`, the esp32c6 support the following targets: riscv32imac-esp-espidf,
        riscv32imac-unknown-none-elf
  • I have reproduced the bug in main branch too

Expected behavior

cargo-espflash should honor CARGO_BUILD_TARGET and behave as if --target=riscv32imac-esp-espidf was supplied.

Environment

  • OS: Ubuntu 25.10 hosting docker image espressif/idf-rust:esp32_1.92.0.0
  • espflash/cargo-espflash version: 4.3.0
  • Target: ESP32-C6

Additional context

I'm using different devcontainer configs for targeting esp32 and esp32c6. In those configs I set CARGO_BUILD_TARGET accordingly. cargo build uses the env variable so it would be helpful if I could also use the same command for flashing without providing --target every time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug juryIssue to be discussed during Bug Jury.

    Type

    No type

    Projects

    Status

    Review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions