Skip to content

Commit

Permalink
Fix duplicated PATH entries
Browse files Browse the repository at this point in the history
  • Loading branch information
chansuke committed Sep 18, 2021
1 parent e3e5cc2 commit d4f51e6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/env_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ pub fn prepend_path(name: &str, value: Vec<PathBuf>, cmd: &mut Command) {
let mut parts: Vec<PathBuf>;
if let Some(ref v) = old_value {
parts = value;
parts.extend(env::split_paths(v).collect::<Vec<_>>());
parts
.iter()
.filter(|&x| x != v)
.cloned()
.collect::<Vec<PathBuf>>()
.extend(env::split_paths(v).collect::<Vec<_>>());
} else {
parts = value;
}
Expand Down

0 comments on commit d4f51e6

Please sign in to comment.