Fix invoking cargo without consulting CARGO or standard installation paths

This commit is contained in:
veetaha 2020-05-23 04:58:22 +03:00
parent 5f7225446e
commit 030d78345f
5 changed files with 16 additions and 5 deletions

View file

@ -48,6 +48,7 @@ hir = { path = "../ra_hir", package = "ra_hir" }
hir_def = { path = "../ra_hir_def", package = "ra_hir_def" }
hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" }
ra_proc_macro_srv = { path = "../ra_proc_macro_srv" }
ra_toolchain = { path = "../ra_toolchain" }
[target.'cfg(windows)'.dependencies]
winapi = "0.3.8"

View file

@ -40,6 +40,7 @@ use crate::{
world::WorldSnapshot,
LspError, Result,
};
use anyhow::Context;
pub fn handle_analyzer_status(world: WorldSnapshot, _: ()) -> Result<String> {
let _p = profile("handle_analyzer_status");
@ -982,10 +983,15 @@ fn to_lsp_runnable(
target.map_or_else(|| "run binary".to_string(), |t| format!("run {}", t))
}
};
let cargo_path = ra_toolchain::cargo()
.to_str()
.context("Path to cargo executable contains invalid UTF8 characters")?
.to_owned();
Ok(lsp_ext::Runnable {
range: to_proto::range(&line_index, runnable.range),
label,
bin: "cargo".to_string(),
bin: cargo_path,
args,
extra_args,
env: {