@@ -7,6 +7,7 @@ use crate::{
77 utils:: { is_conda_env, is_conda_install} ,
88} ;
99use log:: trace;
10+ use pet_utils:: path:: fix_file_path_casing;
1011use std:: {
1112 fs,
1213 path:: { Path , PathBuf } ,
@@ -34,6 +35,7 @@ pub fn get_conda_environment_paths(env_vars: &EnvVariables) -> Vec<PathBuf> {
3435 envs
3536 } ) ;
3637
38+ env_paths = env_paths. iter ( ) . map ( |p| fix_file_path_casing ( p) ) . collect ( ) ;
3739 env_paths. sort ( ) ;
3840 env_paths. dedup ( ) ;
3941 // For each env, check if we have a conda install directory in them and
@@ -145,7 +147,7 @@ pub fn get_conda_envs_from_environment_txt(env_vars: &EnvVariables) -> Vec<PathB
145147 if let Ok ( reader) = fs:: read_to_string ( environment_txt. clone ( ) ) {
146148 trace ! ( "Found environments.txt file {:?}" , environment_txt) ;
147149 for line in reader. lines ( ) {
148- envs. push ( PathBuf :: from ( line. to_string ( ) ) ) ;
150+ envs. push ( fix_file_path_casing ( & PathBuf :: from ( line. to_string ( ) ) ) ) ;
149151 }
150152 }
151153 }
@@ -155,6 +157,8 @@ pub fn get_conda_envs_from_environment_txt(env_vars: &EnvVariables) -> Vec<PathB
155157
156158#[ cfg( windows) ]
157159pub fn get_known_conda_install_locations ( env_vars : & EnvVariables ) -> Vec < PathBuf > {
160+ use pet_utils:: path:: fix_file_path_casing;
161+
158162 let user_profile = env_vars. userprofile . clone ( ) . unwrap_or_default ( ) ;
159163 let program_data = env_vars. programdata . clone ( ) . unwrap_or_default ( ) ;
160164 let all_user_profile = env_vars. allusersprofile . clone ( ) . unwrap_or_default ( ) ;
@@ -200,6 +204,19 @@ pub fn get_known_conda_install_locations(env_vars: &EnvVariables) -> Vec<PathBuf
200204 }
201205 known_paths. sort ( ) ;
202206 known_paths. dedup ( ) ;
207+ // Ensure the casing of the paths are correct.
208+ // Its possible the actual path is in a different case.
209+ // E.g. instead of C:\username\miniconda it might bt C:\username\Miniconda
210+ // We use lower cases above, but it could be in any case on disc.
211+ // We do not want to have duplicates in different cases.
212+ // & we'd like to preserve the case of the original path as on disc.
213+ known_paths = known_paths
214+ . iter ( )
215+ . map ( |p| fix_file_path_casing ( p) )
216+ . collect ( ) ;
217+ known_paths. sort ( ) ;
218+ known_paths. dedup ( ) ;
219+
203220 known_paths
204221}
205222
@@ -243,6 +260,7 @@ pub fn get_known_conda_install_locations(env_vars: &EnvVariables) -> Vec<PathBuf
243260 known_paths. append ( get_known_conda_locations ( env_vars) . as_mut ( ) ) ;
244261 known_paths. sort ( ) ;
245262 known_paths. dedup ( ) ;
263+
246264 known_paths
247265}
248266
0 commit comments