Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
use wsl.exe; fixes microsoft/vscode#51455
Browse files Browse the repository at this point in the history
  • Loading branch information
weinand committed Jun 8, 2018
1 parent 340fe9a commit 290a077
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions src/node/wslSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export function subsystemLinuxPresent(): boolean {
if (!isWindows) {
return false;
}
const bashPath32bitApp = path.join(process.env['SystemRoot'], 'Sysnative', 'bash.exe');
const bashPath64bitApp = path.join(process.env['SystemRoot'], 'System32', 'bash.exe');
const bashPath32bitApp = path.join(process.env['SystemRoot'], 'Sysnative', 'wsl.exe');
const bashPath64bitApp = path.join(process.env['SystemRoot'], 'System32', 'wsl.exe');
const bashPathHost = is64bit ? bashPath64bitApp : bashPath32bitApp;
return fs.existsSync(bashPathHost);
}
Expand All @@ -43,23 +43,23 @@ export interface ILaunchArgs {
export function createLaunchArg(useSubsytemLinux: boolean | undefined, useExternalConsole: boolean, cwd: string | undefined, executable: string, args?: string[], program?: string): ILaunchArgs {

if (useSubsytemLinux && subsystemLinuxPresent()) {
const bashPath32bitApp = path.join(process.env['SystemRoot'], 'Sysnative', 'bash.exe');
const bashPath64bitApp = path.join(process.env['SystemRoot'], 'System32', 'bash.exe');
const bashPath32bitApp = path.join(process.env['SystemRoot'], 'Sysnative', 'wsl.exe');
const bashPath64bitApp = path.join(process.env['SystemRoot'], 'System32', 'wsl.exe');
const bashPathHost = is64bit ? bashPath64bitApp : bashPath32bitApp;
const subsystemLinuxPath = useExternalConsole ? bashPath64bitApp : bashPathHost;

let bashCommand = [executable].concat(args || []).map(element => {
let wslArgs = [executable].concat(args || []).map(element => {
if (element === program) { // workaround for issue #35249
element = element.replace(/\\/g, '/');
}
return element.indexOf(' ') > 0 ? `'${element}'` : element;
}).join(' ');
});

return <ILaunchArgs>{
cwd: cwd,
executable: subsystemLinuxPath,
args: ['-c', bashCommand],
combined: [subsystemLinuxPath].concat(['-c', bashCommand]),
args: wslArgs,
combined: [subsystemLinuxPath].concat(wslArgs),
localRoot: cwd,
remoteRoot: windowsPathToWSLPath(cwd)
};
Expand All @@ -76,5 +76,6 @@ export function createLaunchArg(useSubsytemLinux: boolean | undefined, useExtern

export function spawnSync(useWSL: boolean, executable: string, args?: string[], options?: child_process.SpawnSyncOptions) {
const launchArgs = createLaunchArg(useWSL, false, undefined, executable, args);
launchArgs.args = [ 'node', '--version'];
return child_process.spawnSync(launchArgs.executable, launchArgs.args, useWSL ? undefined : options);
}
4 changes: 2 additions & 2 deletions src/tests/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ suite('Node Debug Adapter', () => {
});

if (process.platform === 'win32') {
const bash32bitPath = Path.join(process.env.SystemRoot, 'SYSNATIVE', 'bash.exe');
const bash64bitPath = Path.join(process.env.SystemRoot, 'System32', 'bash.exe');
const bash32bitPath = Path.join(process.env.SystemRoot, 'SYSNATIVE', 'wsl.exe');
const bash64bitPath = Path.join(process.env.SystemRoot, 'System32', 'wsl.exe');
if (FS.existsSync(bash32bitPath) || FS.existsSync(bash64bitPath)) {

test('should run program using WSL', () => {
Expand Down

0 comments on commit 290a077

Please sign in to comment.