From 85db47ac76c383295caee0c1d4284544b761add9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 6 Nov 2020 11:29:54 +0100 Subject: Ignore RUST_SRC_PATH if it is set to invalid value Folks report a ton of hard-to-diagnose issues, the solution for which is "unset RUST_SRC_PATH". Let's just ignore RUST_SRC_PATH when it won't work anyway! --- crates/project_model/src/sysroot.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'crates/project_model') diff --git a/crates/project_model/src/sysroot.rs b/crates/project_model/src/sysroot.rs index 3fe494729..b0e8863f6 100644 --- a/crates/project_model/src/sysroot.rs +++ b/crates/project_model/src/sysroot.rs @@ -114,8 +114,12 @@ fn discover_sysroot_src_dir(current_dir: &AbsPath) -> Result { if let Ok(path) = env::var("RUST_SRC_PATH") { let path = AbsPathBuf::try_from(path.as_str()) .map_err(|path| format_err!("RUST_SRC_PATH must be absolute: {}", path.display()))?; - log::debug!("Discovered sysroot by RUST_SRC_PATH: {}", path.display()); - return Ok(path); + let core = path.join("core"); + if core.exists() { + log::debug!("Discovered sysroot by RUST_SRC_PATH: {}", path.display()); + return Ok(path); + } + log::debug!("RUST_SRC_PATH is set, but is invalid (no core: {:?}), ignoring", core); } let sysroot_path = { -- cgit v1.2.3