@@ -7,7 +7,7 @@ import { ToolkitError } from '../../errors'
77import { Logger } from '../../logger/logger'
88import { ChildProcess } from '../../utilities/processUtils'
99import { waitUntil } from '../../utilities/timeoutUtils'
10- import { isDebugInstance } from '../../vscode/env'
10+ import { isAmazonInternalOs , isDebugInstance } from '../../vscode/env'
1111
1212export function getNodeExecutableName ( ) : string {
1313 return process . platform === 'win32' ? 'node.exe' : 'node'
@@ -26,12 +26,23 @@ function getEncryptionInit(key: Buffer): string {
2626 return JSON . stringify ( request ) + '\n'
2727}
2828
29+ const al2Config = {
30+ path : '/opt/vsc-sysroot/lib64/ld-linux-x86-64.so.2' ,
31+ args : [ '--library-path' , '/opt/vsc-sysroot/lib64' ] ,
32+ }
33+
2934/**
3035 * Checks that we can actually run the `node` executable and execute code with it.
3136 */
3237export async function validateNodeExe ( nodePath : string , lsp : string , args : string [ ] , logger : Logger ) {
3338 // Check that we can start `node` by itself.
34- const proc = new ChildProcess ( nodePath , [ '-e' , 'console.log("ok " + process.version)' ] , { logging : 'no' } )
39+ const proc = new ChildProcess (
40+ isAmazonInternalOs ( ) ? al2Config . path : nodePath ,
41+ isAmazonInternalOs ( )
42+ ? [ ...al2Config . args , nodePath , '-e' , 'console.log("ok " + process.version)' ]
43+ : [ '-e' , 'console.log("ok " + process.version)' ] ,
44+ { logging : 'no' }
45+ )
3546 const r = await proc . run ( )
3647 const ok = r . exitCode === 0 && r . stdout . includes ( 'ok' )
3748 if ( ! ok ) {
@@ -41,7 +52,12 @@ export async function validateNodeExe(nodePath: string, lsp: string, args: strin
4152 }
4253
4354 // Check that we can start `node …/lsp.js --stdio …`.
44- const lspProc = new ChildProcess ( nodePath , [ lsp , ...args ] , { logging : 'no' } )
55+ const lspProc = new ChildProcess (
56+ isAmazonInternalOs ( ) ? al2Config . path : nodePath ,
57+ isAmazonInternalOs ( ) ? [ ...al2Config . args , nodePath , lsp , ...args ] : [ lsp , ...args ] ,
58+ { logging : 'no' }
59+ )
60+
4561 try {
4662 // Start asynchronously (it never stops; we need to stop it below).
4763 lspProc . run ( ) . catch ( ( e ) => logger . error ( 'failed to run: %s' , lspProc . toString ( false , true ) ) )
@@ -89,8 +105,11 @@ export function createServerOptions({
89105 if ( isDebugInstance ( ) ) {
90106 args . unshift ( '--inspect=6080' )
91107 }
92- const lspProcess = new ChildProcess ( executable , args )
93-
108+ const lspProcess = new ChildProcess (
109+ isAmazonInternalOs ( ) ? al2Config . path : executable ,
110+ isAmazonInternalOs ( ) ? [ ...al2Config . args , executable , ...args ] : args ,
111+ { logging : 'no' }
112+ )
94113 // this is a long running process, awaiting it will never resolve
95114 void lspProcess . run ( )
96115
0 commit comments