Vscode-rust: Cargo not found in "Run Test"

Created on 4 Jul 2019  ·  4Comments  ·  Source: rust-lang/vscode-rust

I am using:
rls: 1.37.0 (124483d 2019-07-01)
rls-vscode: 0.6.1
VS Code: 1.36.0-insider
OS: Linux 4.18.0-22-generic #23~18.04.1-Ubuntu (Ubuntu 18.04 LTS) (using vscode remote, local OS: 18.6.0 Darwin (macOS Mojave 10.14.5))
I am having the full absolute path in rust-client.rlsPath and rust-client.rustupPath.

When using the Run Test feature, the terminal cannot find cargo. Its probably related to the $PATH used by rls/rls-vscode.

> Executing task: cargo test -- --nocapture <test_name> <

/bin/bash: cargo: command not found
The terminal process terminated with exit code: 127

While I can use the reused VSCode terminal to do the same command without error.

Most helpful comment

I found another issue.

I have set vscode setting.json with this option

    "terminal.integrated.inheritEnv": false,  // delete it or set to `true`

delete it or set to true will solve this without changing task.js

All 4 comments

Looks like its the problem from VSCode insider, recent update fix this issue.

I have the same problem.

vscode 1.43.0 78a4c91400152c0f27ba4d363eb56d2835f9903a
vscode rust(rls) 0.7.0
rls 1.41.0 (8f1c275 2019-12-10)
cargo 1.41.0 (626f0f40e 2019-12-03)
OS: Darwin Kernel Version 19.3.0

> Executing task: cargo test -- --nocapture test_2 <
zsh:1: command not found: cargo

I have solved this proplem.

It is obviously that $PATH is wrong.

vi ~/.vscode/extensions/rust-lang.rust-0.7.0/out/src/tasks.js

add source $HOME/.cargo/env; in cmdLine

function createShellExecution(execution) {
    const { binary, command, args, cwd, env } = execution;
    // const cmdLine = `${command || binary} ${args.join(' ')}`;
    const cmdLine = `source $HOME/.cargo/env; ${command || binary} ${args.join(' ')}`;
    return new vscode_1.ShellExecution(cmdLine, { cwd, env });
}

But I think there will be some better solution than mine. Maybe change the env options in vscode.ShellExecution()?

I found another issue.

I have set vscode setting.json with this option

    "terminal.integrated.inheritEnv": false,  // delete it or set to `true`

delete it or set to true will solve this without changing task.js

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sfackler picture sfackler  ·  6Comments

japert picture japert  ·  4Comments

rpeshkov picture rpeshkov  ·  5Comments

views63 picture views63  ·  5Comments

alexreg picture alexreg  ·  3Comments