@@ -94,17 +94,34 @@ impl CondaManager {
9494 }
9595 }
9696
97- if let Some ( manager) = get_conda_manager ( path) {
98- trace ! ( "1. Found conda manager from path: {:?}" , path) ;
99- Some ( manager)
100- } else {
101- // Possible this is a conda environment in some other location
102- // Such as global env folders location configured via condarc file
103- // Or a conda env created using `-p` flag.
104- // Get the conda install folder from the history file.
105- trace ! ( "1. Find conda manager from install path: {:?}" , path) ;
106- let conda_install_folder = get_conda_installation_used_to_create_conda_env ( path) ?;
97+ // Possible this is a conda environment in some other location
98+ // Such as global env folders location configured via condarc file
99+ // Or a conda env created using `-p` flag.
100+ // Get the conda install folder from the history file.
101+ // Or its in a location such as `~/.conda/envs` or `~/miniconda3/envs` where the conda install folder is not a parent of this path.
102+ trace ! ( "1. Find conda manager from install path: {:?}" , path) ;
103+ if let Some ( conda_install_folder) = get_conda_installation_used_to_create_conda_env ( path) {
107104 get_conda_manager ( & conda_install_folder)
105+ } else {
106+ // If this is a conda env and the parent is `.conda/envs`, then this is definitely NOT a root conda install folder.
107+ // Hence never use conda installs from these env paths.
108+ if let Some ( parent) = path. parent ( ) {
109+ if parent. ends_with ( ".conda/envs" ) {
110+ trace ! (
111+ "Parent path ends with .conda/envs, not a root conda install folder: {:?}" ,
112+ parent
113+ ) ;
114+ return None ;
115+ }
116+ }
117+
118+ if let Some ( manager) = get_conda_manager ( path) {
119+ trace ! ( "1. Found conda manager from path: {:?}" , path) ;
120+ Some ( manager)
121+ } else {
122+ trace ! ( "No conda manager found for path: {:?}" , path) ;
123+ None
124+ }
108125 }
109126 }
110127 pub fn from_info ( executable : & Path , info : & CondaInfo ) -> Option < CondaManager > {
0 commit comments