Skip to content

Commit c2e4003

Browse files
committed
support al2
1 parent 8b7106b commit c2e4003

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

packages/amazonq/src/extension.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import { registerCommands } from './commands'
4343
import { focusAmazonQPanel } from 'aws-core-vscode/codewhispererChat'
4444
import { activate as activateAmazonqLsp } from './lsp/activation'
4545
import { activate as activateInlineCompletion } from './app/inline/activation'
46-
import { isAmazonInternalOs } from 'aws-core-vscode/shared'
4746

4847
export const amazonQContextPrefix = 'amazonq'
4948

@@ -120,10 +119,7 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
120119
}
121120
// This contains every lsp agnostic things (auth, security scan, code scan)
122121
await activateCodeWhisperer(extContext as ExtContext)
123-
if (
124-
(Experiments.instance.get('amazonqLSP', true) || Auth.instance.isInternalAmazonUser()) &&
125-
!isAmazonInternalOs()
126-
) {
122+
if (Experiments.instance.get('amazonqLSP', true) || Auth.instance.isInternalAmazonUser()) {
127123
// start the Amazon Q LSP for internal users first
128124
await activateAmazonqLsp(context)
129125
}

packages/core/src/shared/lsp/utils/platform.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ToolkitError } from '../../errors'
77
import { Logger } from '../../logger/logger'
88
import { ChildProcess } from '../../utilities/processUtils'
99
import { waitUntil } from '../../utilities/timeoutUtils'
10-
import { isDebugInstance } from '../../vscode/env'
10+
import { isAmazonInternalOs, isDebugInstance } from '../../vscode/env'
1111

1212
export 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
*/
3237
export 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

Comments
 (0)