Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions packages/amazonq/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { registerCommands } from './commands'
import { focusAmazonQPanel } from 'aws-core-vscode/codewhispererChat'
import { activate as activateAmazonqLsp } from './lsp/activation'
import { activate as activateInlineCompletion } from './app/inline/activation'
import { isAmazonInternalOs } from 'aws-core-vscode/shared'

export const amazonQContextPrefix = 'amazonq'

Expand Down Expand Up @@ -120,10 +119,7 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
}
// This contains every lsp agnostic things (auth, security scan, code scan)
await activateCodeWhisperer(extContext as ExtContext)
if (
(Experiments.instance.get('amazonqLSP', true) || Auth.instance.isInternalAmazonUser()) &&
!isAmazonInternalOs()
) {
if (Experiments.instance.get('amazonqLSP', true) || Auth.instance.isInternalAmazonUser()) {
// start the Amazon Q LSP for internal users first
await activateAmazonqLsp(context)
}
Expand Down
23 changes: 18 additions & 5 deletions packages/core/src/shared/lsp/utils/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ToolkitError } from '../../errors'
import { Logger } from '../../logger/logger'
import { ChildProcess } from '../../utilities/processUtils'
import { waitUntil } from '../../utilities/timeoutUtils'
import { isDebugInstance } from '../../vscode/env'
import { isAmazonInternalOs, isDebugInstance } from '../../vscode/env'

export function getNodeExecutableName(): string {
return process.platform === 'win32' ? 'node.exe' : 'node'
Expand All @@ -26,12 +26,25 @@ function getEncryptionInit(key: Buffer): string {
return JSON.stringify(request) + '\n'
}

// use dynamic linking to let node binary
// pick up GLIBC >= 2.28
const al2Config = {
path: '/opt/vsc-sysroot/lib64/ld-linux-x86-64.so.2',
args: ['--library-path', '/opt/vsc-sysroot/lib64'],
}
function createNodeProcess(nodePath: string, args: string[]) {
return new ChildProcess(
isAmazonInternalOs() ? al2Config.path : nodePath,
isAmazonInternalOs() ? [...al2Config.args, nodePath, ...args] : [...args],
{ logging: 'no' }
)
}
/**
* Checks that we can actually run the `node` executable and execute code with it.
*/
export async function validateNodeExe(nodePath: string, lsp: string, args: string[], logger: Logger) {
// Check that we can start `node` by itself.
const proc = new ChildProcess(nodePath, ['-e', 'console.log("ok " + process.version)'], { logging: 'no' })
const proc = createNodeProcess(nodePath, ['-e', 'console.log("ok " + process.version)'])
const r = await proc.run()
const ok = r.exitCode === 0 && r.stdout.includes('ok')
if (!ok) {
Expand All @@ -41,7 +54,8 @@ export async function validateNodeExe(nodePath: string, lsp: string, args: strin
}

// Check that we can start `node …/lsp.js --stdio …`.
const lspProc = new ChildProcess(nodePath, [lsp, ...args], { logging: 'no' })
const lspProc = createNodeProcess(nodePath, [lsp, ...args])

try {
// Start asynchronously (it never stops; we need to stop it below).
lspProc.run().catch((e) => logger.error('failed to run: %s', lspProc.toString(false, true)))
Expand Down Expand Up @@ -89,8 +103,7 @@ export function createServerOptions({
if (isDebugInstance()) {
args.unshift('--inspect=6080')
}
const lspProcess = new ChildProcess(executable, args)

const lspProcess = createNodeProcess(executable, args)
// this is a long running process, awaiting it will never resolve
void lspProcess.run()

Expand Down