File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -234,12 +234,12 @@ pub fn resource_id(type_name: &str, name: &str) -> String {
234234}
235235
236236pub fn canonicalize_which ( executable : & str , cwd : Option < & str > ) -> Result < String , DscError > {
237- let mut executable = executable. to_string ( ) . replace ( "/" , std:: path:: MAIN_SEPARATOR_STR ) ;
238- if cfg ! ( target_os = "windows" ) && !executable. ends_with ( ".exe" ) {
239- let mut exe_path = PathBuf :: from ( & executable) ;
240- exe_path. set_extension ( "exe" ) ;
241- executable = exe_path. to_string_lossy ( ) . to_string ( ) ;
237+ // Use PathBuf to handle path separators robustly
238+ let mut executable_path = PathBuf :: from ( executable) ;
239+ if cfg ! ( target_os = "windows" ) && executable_path. extension ( ) . map_or ( true , |ext| ext != "exe" ) {
240+ executable_path. set_extension ( "exe" ) ;
242241 }
242+ let mut executable = executable_path. to_string_lossy ( ) . to_string ( ) ;
243243 if which ( & executable) . is_err ( ) && !Path :: new ( & executable) . is_absolute ( ) && cwd. is_some ( ) {
244244 if let Some ( cwd) = cwd {
245245 let cwd_path = Path :: new ( cwd) ;
You can’t perform that action at this time.
0 commit comments