Skip to content

Commit 731d782

Browse files
committed
Invert the logic for determining if a path is a base conda environment
1 parent 4a1813f commit 731d782

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

crates/uv-python/src/virtualenv.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ impl CondaEnvironmentKind {
8282
/// When the base environment is used, `CONDA_DEFAULT_ENV` will be set to a name, i.e., `base` or
8383
/// `root` which does not match the prefix, e.g. `/usr/local` instead of
8484
/// `/usr/local/conda/envs/<name>`.
85+
///
86+
/// Note the name `CONDA_DEFAULT_ENV` is misleading, it's the current environment, not the base
87+
/// environment name.
8588
fn from_prefix_path(path: &Path) -> Self {
8689
// If we cannot read `CONDA_DEFAULT_ENV`, there's no way to know if the base environment
8790
let Ok(default_env) = env::var(EnvVars::CONDA_DEFAULT_ENV) else {
@@ -98,9 +101,9 @@ impl CondaEnvironmentKind {
98101
};
99102

100103
if name.to_str().is_some_and(|name| name == default_env) {
101-
Self::Base
102-
} else {
103104
Self::Child
105+
} else {
106+
Self::Base
104107
}
105108
}
106109
}

0 commit comments

Comments
 (0)