Skip to content

Commit d914399

Browse files
committed
Fix discovery of native conda locator (#23361)
1 parent 9f4ed59 commit d914399

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

native_locator/src/conda.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,11 @@ fn get_known_conda_locations(environment: &impl known::Environment) -> Vec<PathB
181181
PathBuf::from("/home/miniconda3/bin"),
182182
PathBuf::from("/anaconda3/bin"),
183183
PathBuf::from("/miniconda3/bin"),
184-
PathBuf::from("/usr/local/anaconda3/bin"),
185-
PathBuf::from("/usr/local/miniconda3/bin"),
186-
PathBuf::from("/usr/anaconda3/bin"),
187-
PathBuf::from("/usr/miniconda3/bin"),
188-
PathBuf::from("/home/anaconda3/bin"),
189-
PathBuf::from("/home/miniconda3/bin"),
190-
PathBuf::from("/anaconda3/bin"),
191-
PathBuf::from("/miniconda3/bin"),
192184
];
185+
if let Some(home) = environment.get_user_home() {
186+
known_paths.push(PathBuf::from(home.clone()).join("anaconda3/bin"));
187+
known_paths.push(PathBuf::from(home).join("miniconda3/bin"));
188+
}
193189
known_paths.append(&mut environment.get_know_global_search_locations());
194190
known_paths
195191
}
@@ -201,9 +197,10 @@ fn find_conda_binary_in_known_locations(environment: &impl known::Environment) -
201197
for location in known_locations {
202198
for bin in &conda_bin_names {
203199
let conda_path = location.join(bin);
204-
let metadata = std::fs::metadata(&conda_path).ok()?;
205-
if metadata.is_file() || metadata.is_symlink() {
206-
return Some(conda_path);
200+
if let Some(metadata) = std::fs::metadata(&conda_path).ok() {
201+
if metadata.is_file() || metadata.is_symlink() {
202+
return Some(conda_path);
203+
}
207204
}
208205
}
209206
}

0 commit comments

Comments
 (0)