From b9b33d2877b3137dcf80dd7aedcbfcfdfa251b7d Mon Sep 17 00:00:00 2001 From: Elie Richa Date: Mon, 2 Mar 2026 16:04:43 +0100 Subject: [PATCH] include debug extension host env in shell env (#241078) (#298276) * include debug extension host env in shell env (#241078) * Use terminalEnvironment.mergeEnvironments for platform-specific considerations Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Clone the shell env to avoid mutation of a shared object --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../terminal/electron-browser/localTerminalBackend.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/electron-browser/localTerminalBackend.ts b/src/vs/workbench/contrib/terminal/electron-browser/localTerminalBackend.ts index 4435552b283..e30e2c69b46 100644 --- a/src/vs/workbench/contrib/terminal/electron-browser/localTerminalBackend.ts +++ b/src/vs/workbench/contrib/terminal/electron-browser/localTerminalBackend.ts @@ -37,6 +37,7 @@ import { IStatusbarService } from '../../../services/statusbar/browser/statusbar import { memoize } from '../../../../base/common/decorators.js'; import { StopWatch } from '../../../../base/common/stopwatch.js'; import { IRemoteAgentService } from '../../../services/remote/common/remoteAgentService.js'; +import { INativeWorkbenchEnvironmentService } from '../../../services/environment/electron-browser/environmentService.js'; import { shouldUseEnvironmentVariableCollection } from '../../../../platform/terminal/common/terminalEnvironment.js'; import { DisposableStore, MutableDisposable } from '../../../../base/common/lifecycle.js'; @@ -95,6 +96,7 @@ class LocalTerminalBackend extends BaseTerminalBackend implements ITerminalBacke @INativeHostService private readonly _nativeHostService: INativeHostService, @IStatusbarService statusBarService: IStatusbarService, @IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService, + @INativeWorkbenchEnvironmentService private readonly _environmentService: INativeWorkbenchEnvironmentService, ) { super(_localPtyService, logService, historyService, _configurationResolverService, statusBarService, workspaceContextService); @@ -294,7 +296,14 @@ class LocalTerminalBackend extends BaseTerminalBackend implements ITerminalBacke @memoize async getShellEnvironment(): Promise { - return this._shellEnvironmentService.getShellEnv(); + const env = { ... await this._shellEnvironmentService.getShellEnv() }; + + // If running in the context of an extension development host, include the environment derived from the launch configuration + if (this._environmentService.debugExtensionHost.env) { + terminalEnvironment.mergeEnvironments(env, this._environmentService.debugExtensionHost.env); + } + + return env; } async getWslPath(original: string, direction: 'unix-to-win' | 'win-to-unix'): Promise {