Skip to content
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

Revert "remote-cli not being added to PATH with "terminal.integrated.inheritEnv": false" #143201

Merged
merged 1 commit into from
Feb 16, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 18 additions & 21 deletions src/vs/server/node/extensionHostConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@ import { IProcessEnvironment, isWindows } from 'vs/base/common/platform';
import { logRemoteEntry } from 'vs/workbench/services/extensions/common/remoteConsoleUtil';
import { removeDangerousEnvVariables } from 'vs/base/node/processes';

export async function buildUserEnvironment(startParamsEnv: { [key: string]: string | null } = {}, withUserShellEnvironment: boolean, language: string, isDebug: boolean, environmentService: IServerEnvironmentService, logService: ILogService): Promise<IProcessEnvironment> {
export async function buildUserEnvironment(startParamsEnv: { [key: string]: string | null } = {}, language: string, isDebug: boolean, environmentService: IServerEnvironmentService, logService: ILogService): Promise<IProcessEnvironment> {
const nlsConfig = await getNLSConfiguration(language, environmentService.userDataPath);

let userShellEnv: typeof process.env = {};
if (withUserShellEnvironment) {
try {
userShellEnv = await getResolvedShellEnv(logService, environmentService.args, process.env);
} catch (error) {
logService.error('ExtensionHostConnection#buildUserEnvironment resolving shell environment failed', error);
}
let userShellEnv: typeof process.env | undefined = undefined;
try {
userShellEnv = await getResolvedShellEnv(logService, environmentService.args, process.env);
} catch (error) {
logService.error('ExtensionHostConnection#buildUserEnvironment resolving shell environment failed', error);
userShellEnv = {};
}

const binFolder = environmentService.isBuilt ? join(environmentService.appRoot, 'bin') : join(environmentService.appRoot, 'resources', 'server', 'bin-dev');
const remoteCliBinFolder = join(binFolder, 'remote-cli'); // contains the `code` command that can talk to the remote server
const processEnv = process.env;
let PATH = startParamsEnv['PATH'] || (userShellEnv ? userShellEnv['PATH'] : undefined) || processEnv['PATH'];
if (PATH) {
PATH = remoteCliBinFolder + delimiter + PATH;
} else {
PATH = remoteCliBinFolder;
}

const env: IProcessEnvironment = {
...processEnv,
Expand All @@ -50,23 +57,13 @@ export async function buildUserEnvironment(startParamsEnv: { [key: string]: stri
},
...startParamsEnv
};

const binFolder = environmentService.isBuilt ? join(environmentService.appRoot, 'bin') : join(environmentService.appRoot, 'resources', 'server', 'bin-dev');
const remoteCliBinFolder = join(binFolder, 'remote-cli'); // contains the `code` command that can talk to the remote server

let PATH = env.PATH;
if (PATH) {
PATH = remoteCliBinFolder + delimiter + PATH;
} else {
PATH = remoteCliBinFolder;
}
setCaseInsensitive(env, 'PATH', PATH);

if (!environmentService.args['without-browser-env-var']) {
env.BROWSER = join(binFolder, 'helpers', isWindows ? 'browser.cmd' : 'browser.sh'); // a command that opens a browser on the local machine
}

setCaseInsensitive(env, 'PATH', PATH);
removeNulls(env);

return env;
}

Expand Down Expand Up @@ -192,7 +189,7 @@ export class ExtensionHostConnection {
execArgv = [`--inspect${startParams.break ? '-brk' : ''}=${startParams.port}`];
}

const env = await buildUserEnvironment(startParams.env, true, startParams.language, !!startParams.debugId, this._environmentService, this._logService);
const env = await buildUserEnvironment(startParams.env, startParams.language, !!startParams.debugId, this._environmentService, this._logService);
removeDangerousEnvVariables(env);

const opts = {
Expand Down
8 changes: 7 additions & 1 deletion src/vs/server/node/remoteTerminalChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,13 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
};


const baseEnv = await buildUserEnvironment(args.resolverEnv, !!args.shellLaunchConfig.useShellEnvironment, platform.language, false, this._environmentService, this._logService);
let baseEnv: platform.IProcessEnvironment;
if (args.shellLaunchConfig.useShellEnvironment) {
this._logService.trace('*');
baseEnv = await buildUserEnvironment(args.resolverEnv, platform.language, false, this._environmentService, this._logService);
} else {
baseEnv = this._getEnvironment();
}
this._logService.trace('baseEnv', baseEnv);

const reviveWorkspaceFolder = (workspaceData: IWorkspaceFolderData): IWorkspaceFolder => {
Expand Down