From 9abc283132a9a6cceaac3780194b1b23dfd8bb92 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Wed, 17 Jul 2024 13:31:19 +0200 Subject: [PATCH] Fix PATH variable splitting on Windows --- lib/system/env/mod.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/system/env/mod.rs b/lib/system/env/mod.rs index 1da3696..3060397 100644 --- a/lib/system/env/mod.rs +++ b/lib/system/env/mod.rs @@ -1,4 +1,7 @@ -use std::{env::var, path::MAIN_SEPARATOR_STR}; +use std::{ + env::{split_paths, var_os}, + path::MAIN_SEPARATOR_STR, +}; use crate::{result::RokitResult, storage::Home}; @@ -39,7 +42,7 @@ pub async fn add_to_path(home: &Home) -> RokitResult { #[must_use] pub fn exists_in_path(_home: &Home) -> bool { let pattern = format!("rokit{MAIN_SEPARATOR_STR}bin"); - var("PATH") - .map(|path| path.split(':').any(|item| item.ends_with(&pattern))) - .unwrap_or(false) + var_os("PATH").map_or(false, |path| { + split_paths(&path).any(|item| item.ends_with(&pattern)) + }) }