Rust with ESP in Devcontainer

lg.lindstrom
Posts: 48
Joined: Fri Sep 17, 2021 4:02 pm

Rust with ESP in Devcontainer

Postby lg.lindstrom » Wed May 29, 2024 3:33 pm

Hi

I decided to try out Rust for ESP development.

As first action I installed Rust on my Windows 11 computer using rustup.

After that I created a new project using cargo and a template from ESP-RS.

Running this template I got the option to use VsCode Devcontainer which was what I aimed for.

The create process went well and I started VsCode in the newly created folder.

VsCode recognized the Devcontainer configuration ant started up a container.

It took a while but finally I was up and running.

So, my problem:
- The rust analyzer shows a error:

Code: Select all

cargo check failed to start: Cargo watcher failed, the command produced no valid metadata (exit code: ExitStatus(unix_wait_status(256))):

error: 'cargo-clippy' is not installed for the custom toolchain '/home/esp/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu'.

note: this is a custom toolchain, which cannot use `rustup component add`

help: if you built this toolchain from source, and used `rustup toolchain link`, then you may be able to build the component with `x.py`
VsCode footer also indicates this error.

There is another small but irritation error also.
The VsCode footer have a small "build" button. Press the button and you will be promted about you would like to build for "release" or "debug".
Whatever you select you will get this error:

Code: Select all

Executing task: scripts/build.sh release 

/bin/bash: line 1: scripts/build.sh: cannot execute: required file not found

 *  The terminal process "/bin/bash '-c', 'scripts/build.sh release'" failed to launch (exit code: 127). 
 *  Terminal will be reused by tasks, press any key to close it.
Any good advice how to correct this errors??
My Devcontainer is below.

Code: Select all

{
  "name": "test1",
  // Select between image and build propieties to pull or build the image.
  // "image": "docker.io/espressif/idf-rust:esp32c2_latest",
  "build": {
    "dockerfile": "Dockerfile",
    "args": {
      "CONTAINER_USER": "esp",
      "CONTAINER_GROUP": "esp",
      "ESP_BOARD": "esp32c2"
    }
  },
  "settings": {
    "editor.formatOnPaste": true,
    "editor.formatOnSave": true,
    "editor.formatOnSaveMode": "file",
    "editor.formatOnType": true,
    "lldb.executable": "/usr/bin/lldb",
    "files.watcherExclude": {
      "**/target/**": true
    },
    "rust-analyzer.checkOnSave.command": "clippy",
    "rust-analyzer.checkOnSave.allTargets": false,
    "[rust]": {
      "editor.defaultFormatter": "rust-lang.rust-analyzer"
    }
  },
  "extensions": [
    "rust-lang.rust-analyzer",
    "tamasfe.even-better-toml",
    "serayuzgur.crates",
    "mutantdino.resourcemonitor",
    "yzhang.markdown-all-in-one",
    "ms-vscode.cpptools",
    "actboy168.tasks",
    "Wokwi.wokwi-vscode"
  ],
  "forwardPorts": [
    3333,
    8000
  ],
  "workspaceMount": "source=${localWorkspaceFolder},target=/home/esp/test1,type=bind,consistency=cached",
  "workspaceFolder": "/home/esp/test1"
}

Who is online

Users browsing this forum: No registered users and 3 guests