🙆

[Rust, Windows11] Can't run Rust on VSCode

2024/06/21に公開

When I run "src\main.rs" on VSCode, I got the Error like below.

Path to shell executable "PATH_TO_PROJECT\cargo" does not exist.

Environment: Windows11, VSCode 1.85.1

details

Here is my step.

  1. create new project
    > cargo new projectName
    
  2. open the project on VSCode
  3. open "src\main.rs" on VSCode
  4. run "src\main.rs"
  5. The error appeared

Solution

  1. I added this setting on VSCode.
    "rust-analyzer.runnableEnv": {"PATH": "C:\\Users\\USER_NAME\\.cargo\\bin"}
    
  2. And I restarted VSCode.
  3. Then I could run "src\main.rs".

reference:
https://github.com/rust-lang/rust-analyzer/issues/11673

P.S.
Then I thought about getting the Full error messages to write this post, so I commented out the setting on VSCode.
But the Error didn't happen again.
I'm not sure Why...

Discussion