Skip to content

Do not use conda run when launching a debugger #18858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/18847.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix launch of Python Debugger when using conda environments.
35 changes: 1 addition & 34 deletions src/client/debugger/extension/adapter/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { IApplicationShell } from '../../../common/application/types';
import { EXTENSION_ROOT_DIR } from '../../../constants';
import { IInterpreterService } from '../../../interpreter/contracts';
import { traceLog, traceVerbose } from '../../../logging';
import { Conda } from '../../../pythonEnvironments/common/environmentManagers/conda';
import { EnvironmentType, PythonEnvironment } from '../../../pythonEnvironments/info';
import { PythonEnvironment } from '../../../pythonEnvironments/info';
import { sendTelemetryEvent } from '../../../telemetry';
import { EventName } from '../../../telemetry/constants';
import { AttachRequestArguments, LaunchRequestArguments } from '../../types';
Expand Down Expand Up @@ -143,40 +142,8 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
return this.getExecutableCommand(interpreters[0]);
}

private async getCondaCommand(): Promise<Conda | undefined> {
const condaCommand = await Conda.getConda();
const isCondaRunSupported = await condaCommand?.isCondaRunSupported();
return isCondaRunSupported ? condaCommand : undefined;
}

private async getExecutableCommand(interpreter: PythonEnvironment | undefined): Promise<string[]> {
if (interpreter) {
if (interpreter.envType === EnvironmentType.Conda) {
const condaCommand = await this.getCondaCommand();
if (condaCommand) {
if (interpreter.envName) {
return [
condaCommand.command,
'run',
'-n',
interpreter.envName,
'--no-capture-output',
'--live-stream',
'python',
];
} else if (interpreter.envPath) {
return [
condaCommand.command,
'run',
'-p',
interpreter.envPath,
'--no-capture-output',
'--live-stream',
'python',
];
}
}
}
return interpreter.path.length > 0 ? [interpreter.path] : [];
}
return [];
Expand Down