Skip to content

Commit 9fdbafa

Browse files
committed
Don't use activate from inside conda environments
In contrast to virtualenv-created environments, conda environments are not activated from the inside. In constrast, the environment activation is done from the outside via the conda executable that created the environment. Fixes #4402
1 parent 8cd0996 commit 9fdbafa

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/client/interpreter/locators/services/condaService.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,24 +250,14 @@ export class CondaService implements ICondaService {
250250
const condaExe = this.platform.isWindows ? 'conda.exe' : 'conda';
251251
const scriptsDir = this.platform.isWindows ? 'Scripts' : 'bin';
252252
const interpreterDir = interpreterPath ? path.dirname(interpreterPath) : '';
253-
let condaPath = path.join(interpreterDir, condaExe);
254-
if (await this.fileSystem.fileExists(condaPath)) {
255-
return condaPath;
256-
}
257-
// Conda path has changed locations, check the new location in the scripts directory after checking
258-
// the old location
259-
condaPath = path.join(interpreterDir, scriptsDir, condaExe);
260-
if (await this.fileSystem.fileExists(condaPath)) {
261-
return condaPath;
262-
}
263253

264254
// Might be in a situation where this is not the default python env, but rather one running
265255
// from a virtualenv
266256
const envsPos = envName ? interpreterDir.indexOf(path.join('envs', envName)) : -1;
267257
if (envsPos > 0) {
268258
// This should be where the original python was run from when the environment was created.
269259
const originalPath = interpreterDir.slice(0, envsPos);
270-
condaPath = path.join(originalPath, condaExe);
260+
let condaPath = path.join(originalPath, condaExe);
271261

272262
if (await this.fileSystem.fileExists(condaPath)) {
273263
return condaPath;
@@ -279,6 +269,17 @@ export class CondaService implements ICondaService {
279269
return condaPath;
280270
}
281271
}
272+
273+
let condaPath = path.join(interpreterDir, condaExe);
274+
if (await this.fileSystem.fileExists(condaPath)) {
275+
return condaPath;
276+
}
277+
// Conda path has changed locations, check the new location in the scripts directory after checking
278+
// the old location
279+
condaPath = path.join(interpreterDir, scriptsDir, condaExe);
280+
if (await this.fileSystem.fileExists(condaPath)) {
281+
return condaPath;
282+
}
282283
}
283284

284285
/**

0 commit comments

Comments
 (0)