Skip to content

Commit c8fa9e2

Browse files
committed
use env var
1 parent 0f6791e commit c8fa9e2

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

packages/amazonq/src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { registerCommands } from './commands'
4444
import { focusAmazonQPanel } from 'aws-core-vscode/codewhispererChat'
4545
import { activate as activateAmazonqLsp } from './lsp/activation'
4646
import { activate as activateInlineCompletion } from './app/inline/activation'
47-
import { getGlibcPath } from './lsp/client'
47+
import { hasGlibcPatch } from './lsp/client'
4848

4949
export const amazonQContextPrefix = 'amazonq'
5050

@@ -123,7 +123,7 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
123123
await activateCodeWhisperer(extContext as ExtContext)
124124
if (
125125
(Experiments.instance.get('amazonqLSP', true) || Auth.instance.isInternalAmazonUser()) &&
126-
(!isAmazonLinux2() || (await getGlibcPath()))
126+
(!isAmazonLinux2() || hasGlibcPatch())
127127
) {
128128
// start the Amazon Q LSP for internal users first
129129
// for AL2, start LSP if glibc patch is found

packages/amazonq/src/lsp/client.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
undefinedIfEmpty,
3333
getOptOutPreference,
3434
isAmazonLinux2,
35-
fs,
3635
getClientId,
3736
} from 'aws-core-vscode/shared'
3837
import { processUtils } from 'aws-core-vscode/shared'
@@ -44,16 +43,11 @@ import { telemetry } from 'aws-core-vscode/telemetry'
4443
const localize = nls.loadMessageBundle()
4544
const logger = getLogger('amazonqLsp.lspClient')
4645

47-
export async function getGlibcPath(): Promise<string | undefined> {
48-
for (const file of [
49-
'/opt/vsc-sysroot/lib64/ld-linux-x86-64.so.2',
50-
'/opt/vsc-sysroot/lib64/ld-linux-aarch64.so.1',
51-
]) {
52-
if (await fs.exists(file)) {
53-
return file
54-
}
55-
}
56-
return undefined
46+
export const glibcLinker: string = process.env.VSCODE_SERVER_CUSTOM_GLIBC_LINKER || ''
47+
export const glibcPath: string = process.env.VSCODE_SERVER_CUSTOM_GLIBC_PATH || ''
48+
49+
export function hasGlibcPatch(): boolean {
50+
return glibcLinker.length > 0 && glibcPath.length > 0
5751
}
5852

5953
export async function startLanguageServer(
@@ -78,9 +72,8 @@ export async function startLanguageServer(
7872
const traceServerEnabled = Settings.instance.isSet(`${clientId}.trace.server`)
7973
let executable: string[] = []
8074
// apply the GLIBC 2.28 path to node js runtime binary
81-
const glibcPath = await getGlibcPath()
82-
if (isAmazonLinux2() && glibcPath) {
83-
executable = [glibcPath, '--library-path', '/opt/vsc-sysroot/lib64', resourcePaths.node]
75+
if (isAmazonLinux2() && hasGlibcPatch()) {
76+
executable = [glibcLinker, '--library-path', glibcPath, resourcePaths.node]
8477
getLogger('amazonqLsp').info(`Patched node runtime with GLIBC to ${executable}`)
8578
} else {
8679
executable = [resourcePaths.node]

0 commit comments

Comments
 (0)