@@ -174,8 +174,15 @@ impl CondaLocator for Conda {
174
174
if environments. contains_key ( & conda_env. prefix ) {
175
175
continue ;
176
176
}
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 ( ) ) ) ;
179
186
environments. insert ( conda_env. prefix . clone ( ) , env. clone ( ) ) ;
180
187
reporter. report_manager ( & manager. to_manager ( ) ) ;
181
188
reporter. report_environment ( & env) ;
@@ -248,18 +255,15 @@ impl Locator for Conda {
248
255
if let Some ( env) = get_conda_environment_info ( path, & None ) {
249
256
if let Some ( conda_dir) = & env. conda_dir {
250
257
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 ( ) ) ) ;
255
259
environments. insert ( path. clone ( ) , env. clone ( ) ) ;
256
260
return Some ( env) ;
257
261
} else {
258
262
// We will still return the conda env even though we do not have the manager.
259
263
// This might seem incorrect, however the tool is about discovering environments.
260
264
// The client can activate this env either using another conda manager or using the activation scripts
261
265
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 ) ;
263
267
environments. insert ( path. clone ( ) , env. clone ( ) ) ;
264
268
return Some ( env) ;
265
269
}
@@ -268,7 +272,7 @@ impl Locator for Conda {
268
272
// This might seem incorrect, however the tool is about discovering environments.
269
273
// The client can activate this env either using another conda manager or using the activation scripts
270
274
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 ) ;
272
276
environments. insert ( path. clone ( ) , env. clone ( ) ) ;
273
277
return Some ( env) ;
274
278
}
@@ -301,7 +305,7 @@ impl Locator for Conda {
301
305
// The client can activate this env either using another conda manager or using the activation scripts
302
306
error ! ( "Unable to find Conda Manager for the Conda env: {:?}" , env) ;
303
307
let prefix = env. prefix . clone ( ) ;
304
- let env = env. to_python_environment ( None , None ) ;
308
+ let env = env. to_python_environment ( None ) ;
305
309
let mut environments = self . environments . lock ( ) . unwrap ( ) ;
306
310
environments. insert ( prefix, env. clone ( ) ) ;
307
311
reporter. report_environment ( & env) ;
@@ -340,7 +344,6 @@ impl Locator for Conda {
340
344
// 5. Report this env.
341
345
if let Some ( manager) = manager {
342
346
let env = env. to_python_environment (
343
- manager. conda_dir . clone ( ) ,
344
347
Some ( manager. to_manager ( ) ) ,
345
348
) ;
346
349
let mut environments = self . environments . lock ( ) . unwrap ( ) ;
@@ -352,7 +355,7 @@ impl Locator for Conda {
352
355
// This might seem incorrect, however the tool is about discovering environments.
353
356
// The client can activate this env either using another conda manager or using the activation scripts
354
357
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 ) ;
356
359
let mut environments = self . environments . lock ( ) . unwrap ( ) ;
357
360
environments. insert ( prefix. clone ( ) , env. clone ( ) ) ;
358
361
reporter. report_environment ( & env) ;
0 commit comments