diff --git a/lib/system/env/unix.rs b/lib/system/env/unix.rs index 64bfbc5..bd74e13 100644 --- a/lib/system/env/unix.rs +++ b/lib/system/env/unix.rs @@ -33,7 +33,7 @@ pub async fn add_to_path(home: &Home) -> RokitResult { // Add the path to known shell profiles let added_any = if let Some(home_dir) = dirs::home_dir() { - Shell::ALL + let futs = Shell::ALL .iter() .map(|shell| { let shell_env_path = home_dir.join(shell.env_file_path()); @@ -44,11 +44,14 @@ pub async fn add_to_path(home: &Home) -> RokitResult { shell_should_create, ) }) - .collect::>() - .collect::>() + .collect::>(); + // NOTE: append_to_shell_file returns `true` if the line was added, + // we need to preserve this information, but also not fail if + // any of the file operations do, so we unwrap_or_default + futs.collect::>() .await - .iter() - .any(Result::is_ok) + .into_iter() + .any(Result::unwrap_or_default) } else { false }; diff --git a/lib/system/env/windows.rs b/lib/system/env/windows.rs index 71643bb..543e3b3 100644 --- a/lib/system/env/windows.rs +++ b/lib/system/env/windows.rs @@ -20,12 +20,9 @@ pub async fn add_to_path(home: &Home) -> RokitResult { let env = key.create_subkey("Environment")?.0; let path = env.get_value::("PATH")?; - let path_already_exists = path.split(';').any(|entry| { - Path::new(entry) - .canonicalize() - .map(|p| p == dir) - .unwrap_or_default() - }); + let path_already_exists = path + .split(';') + .any(|entry| Path::new(entry).canonicalize().is_ok_and(|p| p == dir)); if path_already_exists { Ok::<_, RokitError>(false)