Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conda envs in envs dir cannot be conda install dir #165

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion crates/pet-conda/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,29 @@ use std::path::{Path, PathBuf};

/// conda-meta must exist as this contains a mandatory `history` file.
pub fn is_conda_install(path: &Path) -> bool {
(path.join("condabin").exists() || path.join("envs").exists())
if (path.join("condabin").exists() || path.join("envs").exists())
&& path.join("conda-meta").exists()
{
// For https://github.com/microsoft/vscode-python/issues/24247
// Possible the env has a condabin or envs folder but its not the install directory.
// & in fact its just a regular conda env.
// Easy way is to check if the grand parent folder is a conda install directory.
if let Some(parent) = path.parent() {
if let Some(parent) = parent.parent() {
// If the grand parent is a conda install directory,
// then this is definitely not a conda install dir.
if (parent.join("condabin").exists() || parent.join("envs").exists())
&& parent.join("conda-meta").exists()
{
return false;
}
}
}

return true;
}

false
}

/// conda-meta must exist as this contains a mandatory `history` file.
Expand Down
Loading