esp-rs / std-training

Embedded Rust on Espressif training material.
https://esp-rs.github.io/std-training
Apache License 2.0
606 stars 78 forks source link

rust_analyzer::config failed to find any projects in [AbsPathBuf("/workspace")] #173

Closed iot49 closed 1 year ago

iot49 commented 1 year ago

I get the following errors from rust-analyzer (and the analyzer does not work):

[ERROR rust_analyzer::config] failed to find any projects in [AbsPathBuf("/workspace")]
[ERROR rust_analyzer::main_loop] FetchWorkspaceError:
rust-analyzer failed to discover workspace

I've also noticed that "remoteUser" changed in devcontainer.json from root to esp. With this change the container won't start.

SergioGasquez commented 1 year ago

Do you mind sharing instructions on how to reproduce this? I was able to use the container with VsCode devcontainer and I also get RA working: image

iot49 commented 1 year ago

image

image

iot49 commented 1 year ago

Repo:

esp@4e5d1c01ec6c:/workspace$ whoami
esp
esp@4e5d1c01ec6c:/workspace$ git remote -v
origin  https://github.com/esp-rs/espressif-trainings.git (fetch)
origin  https://github.com/esp-rs/espressif-trainings.git (push)
esp@4e5d1c01ec6c:/workspace$ git diff
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 274b0c3..dd68912 100755
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -17,7 +17,7 @@
     },
     "rust-analyzer.checkOnSave.command": "clippy",
     "[rust]": {
-      "editor.defaultFormatter": "rust-lang.rust-analyzer",
+      "editor.defaultFormatter": "rust-lang.rust-analyzer"
     }
   },
   "extensions": [
@@ -31,4 +31,4 @@
   "remoteUser": "esp",
   "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
   "workspaceFolder": "/workspace"
-}
+}
\ No newline at end of file
diff --git a/intro/hello-world/src/main.rs b/intro/hello-world/src/main.rs
index ad8a230..71b7807 100644
--- a/intro/hello-world/src/main.rs
+++ b/intro/hello-world/src/main.rs
@@ -12,3 +12,4 @@ fn main() {
         sleep(Duration::from_secs(3));
     }
 }
+
esp@4e5d1c01ec6c:/workspace$ 
iot49 commented 1 year ago

Update: I created an entirely new repo with just the hello-world app, and in this case the analyzer works. No idea why it does not with this cloned repo.

SergioGasquez commented 1 year ago

Have you tried opening a project(e.g: intro/hardware-check) instead of the whole repo with VsCode?

iot49 commented 1 year ago

This works. But if I also want to run in a devcontainer I need to create a separate one for each sub-directory (e.g. intro).

On Sun, Apr 2, 2023 at 10:59 PM Sergio Gasquez Arcos < @.***> wrote:

Have you tried opening a project(e.g: intro/hardware-check) instead of the whole repo with VsCode?

— Reply to this email directly, view it on GitHub https://github.com/esp-rs/espressif-trainings/issues/173#issuecomment-1493705189, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATHYSZI6RKLCSU7UGWA7HCTW7JRMJANCNFSM6AAAAAAWPYIG34 . You are receiving this because you authored the thread.Message ID: @.***>

SergioGasquez commented 1 year ago

This works. But if I also want to run in a devcontainer I need to create a separate one for each sub-directory (e.g. intro).

What do you mean? You can open the devcontainer in the espressif-trainings repo, go to the dessired folder in the Vs Code terminal an run code ., this will open the folder in VsCode using the same devcontainer

iot49 commented 1 year ago

Oh, great - I was not aware of this. Solved!

FallProune1 commented 10 months ago

Al momento de crear un archivo en rust me aparece tambien ese error [ERROR rust_analyzer::config] failed to find any projects in [AbsPathBuf("//Desktop/Rust_de_0_a_heroe")] No se porque me aparece esto pero corro el archivo con esta extencion.

Captura de pantalla 2023-12-27 a la(s) 12 17 50 a m

Por favor ayuda :v

SergioGasquez commented 10 months ago

Al momento de crear un archivo en rust me aparece tambien ese error

Why are you truing to create a rust file? Mind-expanding on which project of the training are you trying to use?

No se porque me aparece esto pero corro el archivo con esta extencion.

I would suggest you use the usual cargo commands, at least, until you get it working.

And, please, let's try to keep the issue in English, so everyone can benefit from our conversation.

FallProune1 commented 10 months ago

Thanks, using cargo to create a Rust project worked. Sorry, I'm a beginner in Rust, today I started learning the basics to get started.