diff --git a/news/2 Fixes/18436.md b/news/2 Fixes/18436.md new file mode 100644 index 000000000000..41af906ea823 --- /dev/null +++ b/news/2 Fixes/18436.md @@ -0,0 +1 @@ +Revert to old way of running debugger if conda version less than 4.9.0. diff --git a/src/client/debugger/extension/adapter/factory.ts b/src/client/debugger/extension/adapter/factory.ts index 5f69ca1a1bdb..37d2f669a3cf 100644 --- a/src/client/debugger/extension/adapter/factory.ts +++ b/src/client/debugger/extension/adapter/factory.ts @@ -15,7 +15,7 @@ import { import { IApplicationShell } from '../../../common/application/types'; import { EXTENSION_ROOT_DIR } from '../../../constants'; import { IInterpreterService } from '../../../interpreter/contracts'; -import { traceVerbose } from '../../../logging'; +import { traceLog, traceVerbose } from '../../../logging'; import { Conda } from '../../../pythonEnvironments/common/environmentManagers/conda'; import { EnvironmentType, PythonEnvironment } from '../../../pythonEnvironments/info'; import { sendTelemetryEvent } from '../../../telemetry'; @@ -49,8 +49,14 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac if (configuration.request === 'attach') { if (configuration.connect !== undefined) { + traceLog( + `Connecting to DAP Server at: ${configuration.connect.host ?? '127.0.0.1'}:${ + configuration.connect.port + }`, + ); return new DebugAdapterServer(configuration.connect.port, configuration.connect.host ?? '127.0.0.1'); } else if (configuration.port !== undefined) { + traceLog(`Connecting to DAP Server at: ${configuration.host ?? '127.0.0.1'}:${configuration.port}`); return new DebugAdapterServer(configuration.port, configuration.host ?? '127.0.0.1'); } else if (configuration.listen === undefined && configuration.processId === undefined) { throw new Error('"request":"attach" requires either "connect", "listen", or "processId"'); @@ -70,10 +76,9 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac const logArgs = configuration.logToFile ? ['--log-dir', EXTENSION_ROOT_DIR] : []; if (configuration.debugAdapterPath !== undefined) { - return new DebugAdapterExecutable( - executable, - command.concat([configuration.debugAdapterPath, ...logArgs]), - ); + const args = command.concat([configuration.debugAdapterPath, ...logArgs]); + traceLog(`DAP Server launched with command: ${executable} ${args.join(' ')}`); + return new DebugAdapterExecutable(executable, args); } const debuggerAdapterPathToUse = path.join( @@ -85,8 +90,10 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac 'adapter', ); + const args = command.concat([debuggerAdapterPathToUse, ...logArgs]); + traceLog(`DAP Server launched with command: ${executable} ${args.join(' ')}`); sendTelemetryEvent(EventName.DEBUG_ADAPTER_USING_WHEELS_PATH, undefined, { usingWheels: true }); - return new DebugAdapterExecutable(executable, command.concat([debuggerAdapterPathToUse, ...logArgs])); + return new DebugAdapterExecutable(executable, args); } // Unlikely scenario. @@ -136,10 +143,16 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac return this.getExecutableCommand(interpreters[0]); } + private async getCondaCommand(): Promise { + const condaCommand = await Conda.getConda(); + const isCondaRunSupported = await condaCommand?.isCondaRunSupported(); + return isCondaRunSupported ? condaCommand : undefined; + } + private async getExecutableCommand(interpreter: PythonEnvironment | undefined): Promise { if (interpreter) { if (interpreter.envType === EnvironmentType.Conda) { - const condaCommand = await Conda.getConda(); + const condaCommand = await this.getCondaCommand(); if (condaCommand) { if (interpreter.envName) { return [ diff --git a/src/client/pythonEnvironments/common/environmentManagers/conda.ts b/src/client/pythonEnvironments/common/environmentManagers/conda.ts index c46246ef2017..0db2f81c39d1 100644 --- a/src/client/pythonEnvironments/common/environmentManagers/conda.ts +++ b/src/client/pythonEnvironments/common/environmentManagers/conda.ts @@ -447,4 +447,12 @@ export class Conda { traceError(`Unable to parse version of Conda, ${versionString}`); return new SemVer('0.0.1'); } + + public async isCondaRunSupported(): Promise { + const condaVersion = await this.getCondaVersion(); + if (condaVersion && lt(condaVersion, CONDA_RUN_VERSION)) { + return false; + } + return true; + } }