esp-rs / esp-idf-template

A "Hello, world!" template of a Rust binary crate for the ESP-IDF framework.
373 stars 44 forks source link

IDF v5.0 build errors from fresh template project in Windows 10 - could not find `http` in `embedded_svc` #119

Closed gak closed 1 year ago

gak commented 1 year ago

I set up a fresh project from esp-idf-template and am getting errors on the first attempt. I'm not sure what I'm doing wrong here.

I've tried reinstalling the esp rust toolchain (nuking the directory and reinstalling).

Windows 10

stable-x86_64-pc-windows-msvc unchanged - rustc 1.69.0 (84c898d65 2023-04-16) nightly-x86_64-pc-windows-msvc unchanged - rustc 1.71.0-nightly (cba14074b 2023-05-10)

Ignored package cargo-generate v0.18.2 is already installed, use --force to override Ignored package ldproxy v0.3.3 is already installed, use --force to override Ignored package espup v0.4.0 is already installed, use --force to override Ignored package espflash v1.7.0 is already installed, use --force to override Ignored package cargo-espflash v1.7.0 is already installed, use --force to override

espup update [2023-05-11T09:20:53Z INFO ] Updating Espressif Rust ecosystem [2023-05-11T09:20:53Z INFO ] Querying GitHub API: 'https://api.github.com/repos/esp-rs/rust-build/releases/latest' [2023-05-11T09:20:53Z INFO ] Querying GitHub API: 'https://api.github.com/repos/esp-rs/rust-build/releases' [2023-05-11T09:20:54Z WARN ] Previous installation of Xtensa Rust 1.69.0 exists in: 'C:\Users\xxx.rustup\toolchains\esp'. Reusing this installation. [2023-05-11T09:20:54Z INFO ] Update successfully completed!

cargo generate --git https://github.com/esp-rs/esp-idf-template cargo Project Name: esp32cantbuild Destination: C:\Users\xxx\esp32cantbuild ... project-name: esp32cantbuild ... Generating template ... ✔ Use the default template values? · false ✔ Which MCU to target? · esp32s2 ✔ Configure project to use Dev Containers (VS Code and GitHub Codespaces)? · false ✔ Enable STD support? · true ✔ Configure project to support Wokwi simulation with Wokwi VS Code extension? · false ✔ ESP-IDF version (master = UNSTABLE) · v5.0 ✔ Include esp-idf-hal/esp-idf-svc? · Yes (default features) Done! New project created

Cargo.toml deps:

[dependencies]
esp-idf-sys = { version = "0.32.1", features = ["binstart"] }
esp-idf-hal = { version = "0.40.1"}
esp-idf-svc = { version = "0.45.0"}

[build-dependencies]
embuild = "0.31.1"

# v5.0 and master require patches due to https://github.com/esp-rs/esp-idf-template/issues/91#issuecomment-1508241327
[patch.crates-io]
esp-idf-hal = { git="https://github.com/esp-rs/esp-idf-hal"}
esp-idf-svc = { git="https://github.com/esp-rs/esp-idf-svc"}

cargo run errors: https://gist.github.com/gak/9e25d2ed74d3dd7391503f9c28a44418

I've de-duplicated some of the errors:

error[E0433]: failed to resolve: could not find `asyncify` in `utils`
   --> C:\Users\msn\.cargo\git\checkouts\esp-idf-svc-a28457b0e32c6283\3a53106\src\eventloop.rs:881:30
    |
881 |     use embedded_svc::utils::asyncify::event_bus::AsyncEventBus;
    |                              ^^^^^^^^ could not find `asyncify` in `utils`

error[E0433]: failed to resolve: could not find `http` in `embedded_svc`
  --> C:\Users\msn\.cargo\git\checkouts\esp-idf-svc-a28457b0e32c6283\3a53106\src\http\client.rs:18:19
   |
18 | use embedded_svc::http::client::*;
   |                   ^^^^ could not find `http` in `embedded_svc`

error[E0432]: unresolved import `embedded_svc::ota`
  --> C:\Users\msn\.cargo\git\checkouts\esp-idf-svc-a28457b0e32c6283\3a53106\src\ota.rs:16:5
   |
16 | use embedded_svc::ota;
   |     ^^^^^^^^^^^^^^^^^ no `ota` in the root
   |
help: consider importing this module instead
   |
16 | use crate::ota;
   |     ~~~~~~~~~~

error[E0433]: failed to resolve: use of undeclared type `Method`
  --> C:\Users\msn\.cargo\git\checkouts\esp-idf-svc-a28457b0e32c6283\3a53106\src\http\client.rs:36:17
   |
36 |                 Method::Get => esp_http_client_method_t_HTTP_METHOD_GET,
   |                 ^^^^^^ use of undeclared type `Method`
ivmarkov commented 1 year ago

Can you please move this bug report to esp-idf-template? The bug is there. Basically, you need to explicitly depend on embedded-svc and put a patch of embedded-svc in the [patch-crates.io] section.

ivmarkov commented 1 year ago

If you re-generate your project, it should work fine now, incl. for ESP IDF >= 5.

gak commented 1 year ago

Amazing! Thank you.