Skip to content

Commit eed53a6

Browse files
committed
More updates
1 parent 729ffe6 commit eed53a6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

crates/pet-conda/src/environments.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,8 @@ pub fn get_conda_installation_used_to_create_conda_env(env_path: &Path) -> Optio
147147
}
148148
}
149149

150-
// Possible the env_path is the root conda install folder.
151-
if is_conda_install(env_path) {
152-
return Some(env_path.to_path_buf());
153-
}
154-
150+
// First look for the conda-meta/history file in the environment folder.
151+
// This could be a conda envirment (not root) but has `conda` installed in it.
155152
let conda_meta_history = env_path.join("conda-meta").join("history");
156153
if let Ok(reader) = std::fs::read_to_string(conda_meta_history.clone()) {
157154
if let Some(line) = reader.lines().map(|l| l.trim()).find(|l| {
@@ -169,7 +166,12 @@ pub fn get_conda_installation_used_to_create_conda_env(env_path: &Path) -> Optio
169166
}
170167
}
171168

172-
None
169+
// Possible the env_path is the root conda install folder.
170+
if is_conda_install(env_path) {
171+
Some(env_path.to_path_buf())
172+
} else {
173+
None
174+
}
173175
}
174176

175177
fn get_conda_dir_from_cmd(cmd_line: String) -> Option<PathBuf> {

crates/pet-conda/src/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl CondaManager {
106106
// If this is a conda env and the parent is `.conda/envs`, then this is definitely NOT a root conda install folder.
107107
// Hence never use conda installs from these env paths.
108108
if let Some(parent) = path.parent() {
109-
if parent.ends_with(".conda/envs") {
109+
if parent.ends_with(".conda/envs") || parent.ends_with(".conda\\envs") {
110110
trace!(
111111
"Parent path ends with .conda/envs, not a root conda install folder: {:?}",
112112
parent

0 commit comments

Comments
 (0)