Skip to content

Commit 3dd52fc

Browse files
committed
Always use environment path when running conda environment commands
1 parent b4aa112 commit 3dd52fc

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/client/pythonEnvironments/common/environmentManagers/conda.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,8 @@ export class Conda {
564564
return undefined;
565565
}
566566
const args = [];
567-
if (env.name) {
568-
args.push('-n', env.name);
569-
} else {
570-
args.push('-p', env.prefix);
571-
}
567+
args.push('-p', env.prefix);
568+
572569
const python = [
573570
forShellExecution ? this.shellCommand : this.command,
574571
'run',

src/test/common/process/pythonEnvironment.unit.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,16 @@ suite('CondaEnvironment', () => {
284284

285285
teardown(() => sinon.restore());
286286

287-
test('getExecutionInfo with a named environment should return execution info using the environment name', async () => {
287+
test('getExecutionInfo with a named environment should return execution info using the environment path', async () => {
288288
const condaInfo = { name: 'foo', path: 'bar' };
289289
const env = await createCondaEnv(condaInfo, processService.object, fileSystem.object);
290290

291291
const result = env?.getExecutionInfo(args, pythonPath);
292292

293293
expect(result).to.deep.equal({
294294
command: condaFile,
295-
args: ['run', '-n', condaInfo.name, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT, ...args],
296-
python: [condaFile, 'run', '-n', condaInfo.name, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT],
295+
args: ['run', '-p', condaInfo.path, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT, ...args],
296+
python: [condaFile, 'run', '-p', condaInfo.path, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT],
297297
pythonExecutable: pythonPath,
298298
});
299299
});
@@ -312,12 +312,12 @@ suite('CondaEnvironment', () => {
312312
});
313313
});
314314

315-
test('getExecutionObservableInfo with a named environment should return execution info using conda full path with the name', async () => {
315+
test('getExecutionObservableInfo with a named environment should return execution info using conda full path with the path', async () => {
316316
const condaInfo = { name: 'foo', path: 'bar' };
317317
const expected = {
318318
command: condaFile,
319-
args: ['run', '-n', condaInfo.name, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT, ...args],
320-
python: [condaFile, 'run', '-n', condaInfo.name, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT],
319+
args: ['run', '-p', condaInfo.path, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT, ...args],
320+
python: [condaFile, 'run', '-p', condaInfo.path, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT],
321321
pythonExecutable: pythonPath,
322322
};
323323
const env = await createCondaEnv(condaInfo, processService.object, fileSystem.object);

0 commit comments

Comments
 (0)