Skip to content

Activate environment when not using integrated terminal for debugging #21880

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 2 commits into from
Aug 29, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { getProgram, IDebugEnvironmentVariablesService } from './helper';

@injectable()
export class LaunchConfigurationResolver extends BaseConfigurationResolver<LaunchRequestArguments> {
private isPythonSet = false;
private isCustomPythonSet = false;

constructor(
@inject(IDiagnosticsService)
Expand All @@ -38,7 +38,7 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
debugConfiguration: LaunchRequestArguments,
_token?: CancellationToken,
): Promise<LaunchRequestArguments | undefined> {
this.isPythonSet = debugConfiguration.python !== undefined;
this.isCustomPythonSet = debugConfiguration.python !== undefined;
if (
debugConfiguration.name === undefined &&
debugConfiguration.type === undefined &&
Expand Down Expand Up @@ -110,7 +110,9 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
debugConfiguration.envFile = settings.envFile;
}
let baseEnvVars: EnvironmentVariables | undefined;
if (this.isPythonSet) {
if (this.isCustomPythonSet || debugConfiguration.console !== 'integratedTerminal') {
// We only have the right activated environment present in integrated terminal if no custom Python path
// is specified. Otherwise, we need to explicitly set the variables.
baseEnvVars = await this.environmentActivationService.getActivatedEnvironmentVariables(
workspaceFolder,
await this.interpreterService.getInterpreterDetails(debugConfiguration.python ?? ''),
Expand Down