Skip to content

Commit

Permalink
Ignore RUST_SRC_PATH if it is set to invalid value
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
matklad committed Nov 6, 2020
1 parent 7709b6a commit 85db47a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/project_model/src/sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ fn discover_sysroot_src_dir(current_dir: &AbsPath) -> Result<AbsPathBuf> {
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 = {
Expand Down

0 comments on commit 85db47a

Please sign in to comment.