Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Cargo not found in "Run Test" #620

Closed
harrier-lcc opened this issue Jul 4, 2019 · 4 comments
Closed

Cargo not found in "Run Test" #620

harrier-lcc opened this issue Jul 4, 2019 · 4 comments

Comments

@harrier-lcc
Copy link

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.

@harrier-lcc
Copy link
Author

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

@k7
Copy link

k7 commented Mar 13, 2020

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

@k7
Copy link

k7 commented Mar 14, 2020

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()?

@k7
Copy link

k7 commented Mar 14, 2020

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

matklad pushed a commit to matklad/vscode-rust that referenced this issue Jul 13, 2020
738: Implement lens for impls and support resolving lenses. r=matklad a=kjeremy

Closes rust-lang#620 

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
Co-authored-by: kjeremy <kjeremy@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants