From 3897c2acf5ee1ee47422ece9d877f7d51d129ad3 Mon Sep 17 00:00:00 2001 From: Ricardo Martins Date: Thu, 1 Sep 2016 00:57:03 +0100 Subject: [PATCH] Add workaround for multirust directory in testing The home directory is a dummy one during the tests but the .multirust directory in the real home remains in $PATH. Instead of filtering $HOME/.multirust, it is necessary to filter any $PATH entry containing .multirust as a component. --- src/rustup-cli/self_update.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rustup-cli/self_update.rs b/src/rustup-cli/self_update.rs index 6d0224d42ac..a4eceec325a 100644 --- a/src/rustup-cli/self_update.rs +++ b/src/rustup-cli/self_update.rs @@ -37,7 +37,7 @@ use rustup_utils::utils; use sha2::{Sha256, Digest}; use std::env; use std::env::consts::EXE_SUFFIX; -use std::path::{Path, PathBuf}; +use std::path::{Path, PathBuf, Component}; use std::process::{self, Command}; use std::fs::{self, File}; use std::io::Read; @@ -298,9 +298,9 @@ fn rustc_or_cargo_exists_in_path() -> bool { if let Some(paths) = env::var_os("PATH") { // Ignore rustc and cargo if present in $HOME/.cargo/bin and $HOME/.multirust/, // those are expected - let multirust_meta_path = env::home_dir().map(|path| path.join(".multirust")).unwrap(); let paths = env::split_paths(&paths) - .filter(|path| !path.ends_with(".cargo/bin") && !path.starts_with(&multirust_meta_path)); + .filter(|path| !path.ends_with(".cargo/bin") && + !path.components().any(|c| c == Component::Normal(".multirust".as_ref()))); for path in paths { let rustc = path.join("rustc");