From d4f51e6961b8f63d8fc8ef965f2d35ec5dd6c8ee Mon Sep 17 00:00:00 2001 From: chansuke Date: Sat, 18 Sep 2021 14:14:23 +0900 Subject: [PATCH] Fix duplicated PATH entries --- src/env_var.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/env_var.rs b/src/env_var.rs index ebc7d81bc5e..87008e162a1 100644 --- a/src/env_var.rs +++ b/src/env_var.rs @@ -26,7 +26,12 @@ pub fn prepend_path(name: &str, value: Vec, cmd: &mut Command) { let mut parts: Vec; if let Some(ref v) = old_value { parts = value; - parts.extend(env::split_paths(v).collect::>()); + parts + .iter() + .filter(|&x| x != v) + .cloned() + .collect::>() + .extend(env::split_paths(v).collect::>()); } else { parts = value; }