rust-esp32-std-demo: Could not find specification for target "xtensa-esp32-espidf"

I followed the instructions in the README file, but I get this:

error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --target xtensa-esp32-espidf --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit code: 1)
  --- stderr
  error: Error loading target specification: Could not find specification for target "xtensa-esp32-espidf". Run `rustc --print target-list` for a list of built-in targets

I believe that this is related to the fact that rustup toolchain show does not list an esp toolchain:

$ rustup toolchain list
stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc (default)

I did follow the directions on how to install this toolchain, and indeed the toolchain zipfile did get extracted to the correct place:

$ ls C:\Users\me\.rustup\toolchains\

    Directory: C:\Users\me\.rustup\toolchains

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----           9/15/2021 12:26 PM                esp
d----            5/5/2021  8:28 AM                stable-x86_64-pc-windows-msvc
-a---          10/13/2021  5:41 PM      105402674 rust-1.55.0-dev-x86_64-pc-windows-msvc.zip

However, that directory being there is not enough to cause rustup default esp to succeed:

$ rustup default esp
error: toolchain 'esp' is not installed

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 17 (4 by maintainers)

Most upvoted comments

As a suggestion it might be an idea to add a file to the root of the project called rust-toolchain.toml with the following in

[toolchain]
channel = "esp"

For others to install the toolchain under windows one idea would be to look here

extract the zip then use

rustup toolchain link esp <extractedpath>

To register the toolchain as “esp” in the list of available toolchains

Did anyone have this issue on MacOS (Sonoma 14.4.1)? I have esp in my toolchains however cannot get it to work, tried runnig above command and get the error that the toolchain is not installable. Don’t really know how to proceed here.

I had the same error, but on linux (Ubuntu 23.04). Installed w/:

  • sudo apt install -y git curl gcc clang ninja-build cmake libudev-dev unzip xz-utils python3 python3-pip python3-venv libusb-1.0-0 libssl-dev pkg-config
  • sudo snap install rustup --classic
  • rustup install stable
  • cargo install espup
  • espup install
  • . $HOME/export-esp.sh

Version: rustup 1.24.3 (ce5817a94 2021-05-31)

$ cargo build
error: failed to run 'rustc' to learn about target-specific information

Caused by:
  process didn't exit successfully: `/home/derek/snap/rustup/common/rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names --target xtensa-esp32-espidf --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (exit status: 1)
  --- stderr
  error: Error loading target specification: Could not find specification for target "xtensa-esp32-espidf". Run `rustc --print target-list` for a list of built-in targets

$ rustup default esp
error: toolchain 'esp' is not installed
$ rustup toolchain list
stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu

~/.rustup/toolchains/esp exists, so ran: rustup toolchain link esp ~/.rustup/toolchains/esp

This worked. Ex:

~/projects/rust-esp32-std-demo$ cargo build
   [...]
    Finished dev [optimized + debuginfo] target(s) in 3m 42s