Skip to content

Commit 1b1e118

Browse files
authored
Conda envs in envs dir cannot be conda install dir (#164)
Fixes microsoft/vscode-python#24247
1 parent 451025f commit 1b1e118

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

crates/pet-conda/src/utils.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,29 @@ use std::path::{Path, PathBuf};
55

66
/// conda-meta must exist as this contains a mandatory `history` file.
77
pub fn is_conda_install(path: &Path) -> bool {
8-
(path.join("condabin").exists() || path.join("envs").exists())
8+
if (path.join("condabin").exists() || path.join("envs").exists())
99
&& path.join("conda-meta").exists()
10+
{
11+
// For https://github.com/microsoft/vscode-python/issues/24247
12+
// Possible the env has a condabin or envs folder but its not the install directory.
13+
// & in fact its just a regular conda env.
14+
// Easy way is to check if the grand parent folder is a conda install directory.
15+
if let Some(parent) = path.parent() {
16+
if let Some(parent) = parent.parent() {
17+
// If the grand parent is a conda install directory,
18+
// then this is definitely not a conda install dir.
19+
if (parent.join("condabin").exists() || parent.join("envs").exists())
20+
&& parent.join("conda-meta").exists()
21+
{
22+
return false;
23+
}
24+
}
25+
}
26+
27+
return true;
28+
}
29+
30+
false
1031
}
1132

1233
/// conda-meta must exist as this contains a mandatory `history` file.

0 commit comments

Comments
 (0)