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!
This commit is contained in:
Aleksey Kladov 2020-11-06 11:29:54 +01:00
parent 7709b6a2d4
commit 85db47ac76

View file

@ -114,9 +114,13 @@ 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()))?;
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 = {
let mut rustc = Command::new(toolchain::rustc());