@@ -174,8 +174,15 @@ impl CondaLocator for Conda {
174174 if environments. contains_key ( & conda_env. prefix ) {
175175 continue ;
176176 }
177- let env = conda_env
178- . to_python_environment ( Some ( conda_dir. clone ( ) ) , Some ( manager. to_manager ( ) ) ) ;
177+
178+ // Get the right manager for this conda env.
179+ // Possible the manager is different from the one we got from the conda_dir.
180+ let manager = conda_env
181+ . clone ( )
182+ . conda_dir
183+ . and_then ( |p| CondaManager :: from ( & p) )
184+ . unwrap_or ( manager. clone ( ) ) ;
185+ let env = conda_env. to_python_environment ( Some ( manager. to_manager ( ) ) ) ;
179186 environments. insert ( conda_env. prefix . clone ( ) , env. clone ( ) ) ;
180187 reporter. report_manager ( & manager. to_manager ( ) ) ;
181188 reporter. report_environment ( & env) ;
@@ -248,18 +255,15 @@ impl Locator for Conda {
248255 if let Some ( env) = get_conda_environment_info ( path, & None ) {
249256 if let Some ( conda_dir) = & env. conda_dir {
250257 if let Some ( manager) = self . get_manager ( conda_dir) {
251- let env = env. to_python_environment (
252- Some ( conda_dir. clone ( ) ) ,
253- Some ( manager. to_manager ( ) ) ,
254- ) ;
258+ let env = env. to_python_environment ( Some ( manager. to_manager ( ) ) ) ;
255259 environments. insert ( path. clone ( ) , env. clone ( ) ) ;
256260 return Some ( env) ;
257261 } else {
258262 // We will still return the conda env even though we do not have the manager.
259263 // This might seem incorrect, however the tool is about discovering environments.
260264 // The client can activate this env either using another conda manager or using the activation scripts
261265 error ! ( "Unable to find Conda Manager for env (even though we have a conda_dir): {:?}" , env) ;
262- let env = env. to_python_environment ( Some ( conda_dir . clone ( ) ) , None ) ;
266+ let env = env. to_python_environment ( None ) ;
263267 environments. insert ( path. clone ( ) , env. clone ( ) ) ;
264268 return Some ( env) ;
265269 }
@@ -268,7 +272,7 @@ impl Locator for Conda {
268272 // This might seem incorrect, however the tool is about discovering environments.
269273 // The client can activate this env either using another conda manager or using the activation scripts
270274 error ! ( "Unable to find Conda Manager for env: {:?}" , env) ;
271- let env = env. to_python_environment ( None , None ) ;
275+ let env = env. to_python_environment ( None ) ;
272276 environments. insert ( path. clone ( ) , env. clone ( ) ) ;
273277 return Some ( env) ;
274278 }
@@ -301,7 +305,7 @@ impl Locator for Conda {
301305 // The client can activate this env either using another conda manager or using the activation scripts
302306 error ! ( "Unable to find Conda Manager for the Conda env: {:?}" , env) ;
303307 let prefix = env. prefix . clone ( ) ;
304- let env = env. to_python_environment ( None , None ) ;
308+ let env = env. to_python_environment ( None ) ;
305309 let mut environments = self . environments . lock ( ) . unwrap ( ) ;
306310 environments. insert ( prefix, env. clone ( ) ) ;
307311 reporter. report_environment ( & env) ;
@@ -340,7 +344,6 @@ impl Locator for Conda {
340344 // 5. Report this env.
341345 if let Some ( manager) = manager {
342346 let env = env. to_python_environment (
343- manager. conda_dir . clone ( ) ,
344347 Some ( manager. to_manager ( ) ) ,
345348 ) ;
346349 let mut environments = self . environments . lock ( ) . unwrap ( ) ;
@@ -352,7 +355,7 @@ impl Locator for Conda {
352355 // This might seem incorrect, however the tool is about discovering environments.
353356 // The client can activate this env either using another conda manager or using the activation scripts
354357 error ! ( "Unable to find Conda Manager for Conda env (even though we have a conda_dir {:?}): Env Details = {:?}" , conda_dir, env) ;
355- let env = env. to_python_environment ( Some ( conda_dir . clone ( ) ) , None ) ;
358+ let env = env. to_python_environment ( None ) ;
356359 let mut environments = self . environments . lock ( ) . unwrap ( ) ;
357360 environments. insert ( prefix. clone ( ) , env. clone ( ) ) ;
358361 reporter. report_environment ( & env) ;
0 commit comments