|
6 | 6 | import * as os from 'os'; |
7 | 7 | import * as vscode from 'vscode'; |
8 | 8 | import * as child_process from 'child_process'; |
| 9 | +import { PlatformInformation } from '../platform'; |
9 | 10 |
|
10 | 11 | export interface AttachItem extends vscode.QuickPickItem { |
11 | 12 | id: string; |
@@ -389,33 +390,51 @@ function execChildProcess(process: string, workingDirectory: string): Promise<st |
389 | 390 | }); |
390 | 391 | } |
391 | 392 |
|
| 393 | +// VSCode cannot find the path "c:\windows\system32\bash.exe" as bash.exe is only available on 64bit OS. |
| 394 | +// It can be invoked from "c:\windows\sysnative\bash.exe", so adding "c:\windows\sysnative" to path if we identify |
| 395 | +// VSCode is running in windows and doesn't have it in the path. |
| 396 | +function GetSysNativePathIfNeeded() : Promise<any> { |
| 397 | + return PlatformInformation.GetCurrent().then(platformInfo => { |
| 398 | + let env = process.env; |
| 399 | + if (platformInfo.isWindows && platformInfo.architecture === "x86_64") { |
| 400 | + let sysnative : String = process.env.WINDIR + "\\sysnative"; |
| 401 | + env.Path = process.env.PATH + ";" + sysnative; |
| 402 | + } |
| 403 | + |
| 404 | + return env; |
| 405 | + }); |
| 406 | +} |
| 407 | + |
392 | 408 | function execChildProcessAndOutputErrorToChannel(process: string, workingDirectory: string, channel: vscode.OutputChannel): Promise<string> { |
393 | | - channel.appendLine(`Executing: ${process}`); |
| 409 | + channel.appendLine(`Executing: ${process}`); |
| 410 | + |
394 | 411 | return new Promise<string>((resolve, reject) => { |
395 | | - child_process.exec(process, { cwd: workingDirectory, maxBuffer: 500 * 1024 }, (error: Error, stdout: string, stderr: string) => { |
396 | | - let channelOutput = ""; |
397 | | - |
398 | | - if (stdout && stdout.length > 0) { |
399 | | - channelOutput.concat(stdout); |
400 | | - } |
| 412 | + return GetSysNativePathIfNeeded().then(newEnv => { |
| 413 | + child_process.exec(process, { cwd: workingDirectory, env: newEnv, maxBuffer: 500 * 1024 }, (error: Error, stdout: string, stderr: string) => { |
| 414 | + let channelOutput = ""; |
| 415 | + |
| 416 | + if (stdout && stdout.length > 0) { |
| 417 | + channelOutput.concat(stdout); |
| 418 | + } |
401 | 419 |
|
402 | | - if (stderr && stderr.length > 0) { |
403 | | - channelOutput.concat(stderr); |
404 | | - } |
| 420 | + if (stderr && stderr.length > 0) { |
| 421 | + channelOutput.concat(stderr); |
| 422 | + } |
405 | 423 |
|
406 | | - if (error) { |
407 | | - channelOutput.concat(error.message); |
408 | | - } |
| 424 | + if (error) { |
| 425 | + channelOutput.concat(error.message); |
| 426 | + } |
409 | 427 |
|
410 | 428 |
|
411 | | - if (error || (stderr && stderr.length > 0)) { |
412 | | - channel.append(channelOutput); |
413 | | - channel.show(); |
414 | | - reject(new Error("See remote-attach output")); |
415 | | - return; |
416 | | - } |
| 429 | + if (error || (stderr && stderr.length > 0)) { |
| 430 | + channel.append(channelOutput); |
| 431 | + channel.show(); |
| 432 | + reject(new Error("See remote-attach output")); |
| 433 | + return; |
| 434 | + } |
417 | 435 |
|
418 | | - resolve(stdout); |
| 436 | + resolve(stdout); |
| 437 | + }); |
419 | 438 | }); |
420 | 439 | }); |
421 | 440 |
|
|
0 commit comments