0

My remote server environment is Windows.

After installing rust-analyzer in Visual Studio Code, I tried to use the plugin to generate Run test commands in the code.

However, I encountered an error similar to the following:

Executing task: d:\path\to\projectA\cargo test --package projectA --bin projectA -- logic::test::tests::test_a_func --exact --nocapture

The terminal process failed to launch: Path to shell executable "d:\path\to\projectA\cargo" does not exist.

the d:\path\to\projectA\ was generated by cargo new projectA.

and when I change to projectB, do the same thing, I also encountered the similar error, but the path just change to projectB:

Executing task: d:\path\to\projectB\cargo test --package projectB --bin projectB -- logic::test::tests::test_b_func --exact --nocapture

The terminal process failed to launch: Path to shell executable "d:\path\to\projectB\cargo" does not exist.

I have already made the following settings in VSCode, but didn't work:

{
    "rust-analyzer.server.extraEnv": {
        "RUSTUP_HOME": "C:/Users/name/.rustup",
        "CARGO_HOME": "C:/Users/name/.cargo",
    },
    "terminal.integrated.defaultProfile.windows": "Windows PowerShell",
    "rust-analyzer.runnableEnv": {
        "PATH": "C:/Users/name/.cargo/bin"
    },
}

Can I configure rust-analyzer to use the specific C:/Users/name/.cargo/bin/cargo.exe file? Or have any other solution?

E_net4
  • 27,810
  • 13
  • 101
  • 139
linonon
  • 3
  • 3
  • Is [Rustup](https://rustup.rs/) properly installed? Does the command `where cargo` give you a path to the executable? Related links: https://github.com/rust-lang/rust-analyzer/issues/9721 https://github.com/rust-lang/rust-analyzer/issues/11673 – E_net4 Mar 30 '23 at 07:48
  • @E_net4 yes, I can use `cargo -V` and `rustup -V` to get there version: cargo 1.67.1 (8ecd4f20a 2023-01-10), rustup 1.25.2 (17db695f1 2023-02-01). When I ran the `where.exe cargo` command in the terminal, the terminal did give me the paths of the executables. In contrast to the related links, his cargo executable path does not contain the project path. – linonon Mar 30 '23 at 09:13

1 Answers1

0

It appears there is an issue with the Visual Studio Code Extension 'SSH Remote'.

I found a solution in this discussion: link here

linonon
  • 3
  • 3