From e08e4d3fe1079f6ccb1b781f6089d9e573b81ca6 Mon Sep 17 00:00:00 2001 From: Alexandru Dima Date: Wed, 10 Nov 2021 00:11:12 +0100 Subject: [PATCH] Move `--ms-enable-electron-run-as-node` to a later location (#136786) * Move `--ms-enable-electron-run-as-node` to a later location, which is not fatal in Electron builds that don't know it * undo bad change --- extensions/git/src/askpass.ts | 2 +- resources/darwin/bin/code.sh | 2 +- resources/linux/bin/code.sh | 2 +- resources/win32/bin/code.cmd | 2 +- resources/win32/bin/code.sh | 4 ++-- scripts/code-cli.bat | 2 +- scripts/code-cli.sh | 2 +- scripts/code.sh | 2 +- scripts/node-electron.bat | 2 +- scripts/node-electron.sh | 8 ++++---- src/vs/platform/environment/common/argv.ts | 3 +++ src/vs/platform/environment/node/argv.ts | 1 + src/vs/platform/environment/node/shellEnv.ts | 5 +++-- 13 files changed, 21 insertions(+), 16 deletions(-) diff --git a/extensions/git/src/askpass.ts b/extensions/git/src/askpass.ts index 11c8e367649..e6c21efa9cb 100644 --- a/extensions/git/src/askpass.ts +++ b/extensions/git/src/askpass.ts @@ -83,7 +83,7 @@ export class Askpass implements IIPCHandler { ...this.ipc.getEnv(), GIT_ASKPASS: path.join(__dirname, 'askpass.sh'), VSCODE_GIT_ASKPASS_NODE: process.execPath, - VSCODE_GIT_ASKPASS_EXTRA_ARGS: !!process.versions['electron'] ? '--ms-enable-electron-run-as-node' : '', + VSCODE_GIT_ASKPASS_EXTRA_ARGS: (process.versions['electron'] && process.versions['microsoft-build']) ? '--ms-enable-electron-run-as-node' : '', VSCODE_GIT_ASKPASS_MAIN: path.join(__dirname, 'askpass-main.js') }; } diff --git a/resources/darwin/bin/code.sh b/resources/darwin/bin/code.sh index eae80f95d57..20aee89edf9 100755 --- a/resources/darwin/bin/code.sh +++ b/resources/darwin/bin/code.sh @@ -7,5 +7,5 @@ function realpath() { python -c "import os,sys; print(os.path.realpath(sys.argv[ CONTENTS="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")" ELECTRON="$CONTENTS/MacOS/Electron" CLI="$CONTENTS/Resources/app/out/cli.js" -ELECTRON_RUN_AS_NODE=1 "$ELECTRON" --ms-enable-electron-run-as-node "$CLI" "$@" +ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@" exit $? diff --git a/resources/linux/bin/code.sh b/resources/linux/bin/code.sh index 5d9fb6edefd..73ef78f62dc 100755 --- a/resources/linux/bin/code.sh +++ b/resources/linux/bin/code.sh @@ -50,5 +50,5 @@ fi ELECTRON="$VSCODE_PATH/@@NAME@@" CLI="$VSCODE_PATH/resources/app/out/cli.js" -ELECTRON_RUN_AS_NODE=1 "$ELECTRON" --ms-enable-electron-run-as-node "$CLI" "$@" +ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@" exit $? diff --git a/resources/win32/bin/code.cmd b/resources/win32/bin/code.cmd index 890767b226a..c72e9e28333 100644 --- a/resources/win32/bin/code.cmd +++ b/resources/win32/bin/code.cmd @@ -2,5 +2,5 @@ setlocal set VSCODE_DEV= set ELECTRON_RUN_AS_NODE=1 -"%~dp0..\@@NAME@@.exe" --ms-enable-electron-run-as-node "%~dp0..\resources\app\out\cli.js" %* +"%~dp0..\@@NAME@@.exe" "%~dp0..\resources\app\out\cli.js" --ms-enable-electron-run-as-node %* endlocal diff --git a/resources/win32/bin/code.sh b/resources/win32/bin/code.sh index 25fa85b7b3d..999a5b5445c 100644 --- a/resources/win32/bin/code.sh +++ b/resources/win32/bin/code.sh @@ -43,7 +43,7 @@ if [ $IN_WSL = true ]; then # use the Remote WSL extension if installed WSL_EXT_ID="ms-vscode-remote.remote-wsl" - ELECTRON_RUN_AS_NODE=1 "$ELECTRON" --ms-enable-electron-run-as-node "$CLI" --locate-extension $WSL_EXT_ID >/tmp/remote-wsl-loc.txt 2>/dev/null /tmp/remote-wsl-loc.txt 2>/dev/null > = { 'inspect-extensions': { type: 'string', deprecates: 'debugPluginHost', args: 'port', cat: 't', description: localize('inspect-extensions', "Allow debugging and profiling of extensions. Check the developer tools for the connection URI.") }, 'inspect-brk-extensions': { type: 'string', deprecates: 'debugBrkPluginHost', args: 'port', cat: 't', description: localize('inspect-brk-extensions', "Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.") }, 'disable-gpu': { type: 'boolean', cat: 't', description: localize('disableGPU', "Disable GPU hardware acceleration.") }, + 'ms-enable-electron-run-as-node': { type: 'boolean' }, 'max-memory': { type: 'string', cat: 't', description: localize('maxMemory', "Max memory size for a window (in Mbytes)."), args: 'memory' }, 'telemetry': { type: 'boolean', cat: 't', description: localize('telemetry', "Shows all telemetry events which VS code collects.") }, diff --git a/src/vs/platform/environment/node/shellEnv.ts b/src/vs/platform/environment/node/shellEnv.ts index 0033b39a907..a80d1f69863 100644 --- a/src/vs/platform/environment/node/shellEnv.ts +++ b/src/vs/platform/environment/node/shellEnv.ts @@ -127,13 +127,14 @@ async function doResolveUnixShellEnv(logService: ILogService, token: Cancellatio // handle popular non-POSIX shells const name = basename(systemShellUnix); let command: string, shellArgs: Array; + const extraArgs = (process.versions['electron'] && process.versions['microsoft-build']) ? '--ms-enable-electron-run-as-node' : ''; if (/^pwsh(-preview)?$/.test(name)) { // Older versions of PowerShell removes double quotes sometimes so we use "double single quotes" which is how // you escape single quotes inside of a single quoted string. - command = `& '${process.execPath}' --ms-enable-electron-run-as-node -p '''${mark}'' + JSON.stringify(process.env) + ''${mark}'''`; + command = `& '${process.execPath}' ${extraArgs} -p '''${mark}'' + JSON.stringify(process.env) + ''${mark}'''`; shellArgs = ['-Login', '-Command']; } else { - command = `'${process.execPath}' --ms-enable-electron-run-as-node -p '"${mark}" + JSON.stringify(process.env) + "${mark}"'`; + command = `'${process.execPath}' ${extraArgs} -p '"${mark}" + JSON.stringify(process.env) + "${mark}"'`; if (name === 'tcsh') { shellArgs = ['-ic'];