From be1daa75af3d2d706fa65d660b0fa0fa082d355e Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 11 Aug 2024 15:12:10 +0200 Subject: [PATCH] One create bin_path and fixed_path when needed --- src/commands/use.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/commands/use.rs b/src/commands/use.rs index 71cc5648e..3a7f8f2f3 100644 --- a/src/commands/use.rs +++ b/src/commands/use.rs @@ -185,16 +185,16 @@ fn warn_if_multishell_path_not_in_path_env_var( multishell_path: &std::path::Path, config: &FnmConfig, ) { - let bin_path = if cfg!(unix) { - multishell_path.join("bin") - } else { - multishell_path.to_path_buf() - }; + if let Some(path_var) = std::env::var_os("PATH") { + let bin_path = if cfg!(unix) { + multishell_path.join("bin") + } else { + multishell_path.to_path_buf() + }; - let fixed_path = bin_path.to_str().and_then(shell::maybe_fix_windows_path); - let fixed_path = fixed_path.as_ref().map(|x| &x[..]); + let fixed_path = bin_path.to_str().and_then(shell::maybe_fix_windows_path); + let fixed_path = fixed_path.as_deref(); - if let Some(path_var) = std::env::var_os("PATH") { for path in std::env::split_paths(&path_var) { if bin_path == path || fixed_path == path.to_str() { return;