Vscode-rust: 在“运行测试”中未找到货物

创建于 2019-07-04  ·  4评论  ·  资料来源: rust-lang/vscode-rust

我在用:
rls: 1.37.0 (124483d 2019-07-01)
rls-vscode: 0.6.1
VS 代码: 1.36.0-insider
操作系统: Linux 4.18.0-22-generic #23~18.04.1-Ubuntu (Ubuntu 18.04 LTS)(使用 vscode 远程,本地操作系统: 18.6.0 Darwin (macOS Mojave 10.14.5))
我在rust-client.rlsPathrust-client.rustupPath拥有完整的绝对路径。

使用Run Test功能时,终端找不到货物。 它可能与 rls/rls-vscode 使用的 $PATH 有关。

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

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

虽然我可以使用重用的 VSCode 终端执行相同的命令而不会出错。

最有用的评论

我发现了另一个问题。

我已经用这个选项设置了 vscode setting.json

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

删除它或设置为true将解决这个问题而不改变task.js

所有4条评论

看起来是 VSCode 内部人员的问题,最近的更新解决了这个问题。

我也有同样的问题。

vscode 1.43.0 78a4c91400152c0f27ba4d363eb56d2835f9903a
vscode rust(rls) 0.7.0
rls 1.41.0 (8f1c275 2019-12-10)
货物1.41.0 (626f0f40e 2019-12-03)
操作系统: Darwin Kernel Version 19.3.0

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

我已经解决了这个问题。

很明显$PATH是错误的。

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

source $HOME/.cargo/env;中添加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 });
}

但我认为会有比我更好的解决方案。 也许改变env期权vscode.ShellExecution()

我发现了另一个问题。

我已经用这个选项设置了 vscode setting.json

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

删除它或设置为true将解决这个问题而不改变task.js

此页面是否有帮助?
0 / 5 - 0 等级