Skip to content

Commit

Permalink
Add more search paths and fix CONDA_ROOT env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Jun 5, 2024
1 parent ca12c88 commit 6bed471
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion crates/pet-conda/src/env_variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl EnvVariables {
allusersprofile: env.get_env_var("ALLUSERSPROFILE".to_string()),
programdata: env.get_env_var("PROGRAMDATA".to_string()),
homedrive: env.get_env_var("HOMEDRIVE".to_string()),
conda_root: env.get_env_var("ALLUSERSPROFILE".to_string()),
conda_root: env.get_env_var("CONDA_ROOT".to_string()),
conda_prefix: env.get_env_var("CONDA_PREFIX".to_string()),
condarc: env.get_env_var("CONDARC".to_string()),
xdg_config_home: env.get_env_var("XDG_CONFIG_HOME".to_string()),
Expand Down
35 changes: 22 additions & 13 deletions crates/pet-conda/src/environment_locations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,31 @@ pub fn get_known_conda_install_locations(env_vars: &EnvVariables) -> Vec<PathBuf

#[cfg(unix)]
pub fn get_known_conda_install_locations(env_vars: &EnvVariables) -> Vec<PathBuf> {
let mut known_paths = vec![
PathBuf::from("/opt/anaconda3"),
PathBuf::from("/opt/miniconda3"),
PathBuf::from("/usr/local/anaconda3"),
PathBuf::from("/usr/local/miniconda3"),
PathBuf::from("/usr/anaconda3"),
PathBuf::from("/usr/miniconda3"),
PathBuf::from("/home/anaconda3"),
PathBuf::from("/home/miniconda3"),
PathBuf::from("/anaconda3"),
PathBuf::from("/miniconda3"),
PathBuf::from("/miniforge3"),
PathBuf::from("/miniforge3"),
let mut known_paths = vec![];
let directories_to_look_in = [
"/opt",
"/opt",
"/usr/share",
"/usr/local",
"/usr",
"/home",
"", // We need to look in `/anaconda3` and `/miniconda3` as well.
];
for directory in directories_to_look_in.iter() {
known_paths.push(PathBuf::from(format!("{}/anaconda", directory)));
known_paths.push(PathBuf::from(format!("{}/anaconda3", directory)));
known_paths.push(PathBuf::from(format!("{}/miniconda", directory)));
known_paths.push(PathBuf::from(format!("{}/miniconda3", directory)));
known_paths.push(PathBuf::from(format!("{}/miniforge", directory)));
known_paths.push(PathBuf::from(format!("{}/miniforge3", directory)));
}
if let Some(ref conda_root) = env_vars.conda_root {
known_paths.push(PathBuf::from(conda_root.clone()));
}
if let Some(ref home) = env_vars.home {
known_paths.push(home.clone().join("anaconda"));
known_paths.push(home.clone().join("anaconda3"));
known_paths.push(home.clone().join("miniconda"));
known_paths.push(home.clone().join("miniconda3"));
known_paths.push(home.clone().join("miniforge3"));
known_paths.push(home.join(".conda"));
Expand Down

0 comments on commit 6bed471

Please sign in to comment.