@@ -38,6 +38,7 @@ import {
3838 isAmazonLinux2 ,
3939 getClientId ,
4040 extensionVersion ,
41+ isSageMaker ,
4142} from 'aws-core-vscode/shared'
4243import { processUtils } from 'aws-core-vscode/shared'
4344import { activate } from './chat/activation'
@@ -53,11 +54,24 @@ import { InlineChatTutorialAnnotation } from '../app/inline/tutorials/inlineChat
5354const localize = nls . loadMessageBundle ( )
5455const logger = getLogger ( 'amazonqLsp.lspClient' )
5556
56- export const glibcLinker : string = process . env . VSCODE_SERVER_CUSTOM_GLIBC_LINKER || ''
57- export const glibcPath : string = process . env . VSCODE_SERVER_CUSTOM_GLIBC_PATH || ''
58-
5957export function hasGlibcPatch ( ) : boolean {
60- return glibcLinker . length > 0 && glibcPath . length > 0
58+ // Skip GLIBC patching for SageMaker environments
59+ if ( isSageMaker ( ) ) {
60+ getLogger ( 'amazonqLsp' ) . info ( 'SageMaker environment detected in hasGlibcPatch, skipping GLIBC patching' )
61+ return false // Return false to ensure SageMaker doesn't try to use GLIBC patching
62+ }
63+
64+ // Check for environment variables (for CDM)
65+ const glibcLinker = process . env . VSCODE_SERVER_CUSTOM_GLIBC_LINKER || ''
66+ const glibcPath = process . env . VSCODE_SERVER_CUSTOM_GLIBC_PATH || ''
67+
68+ if ( glibcLinker . length > 0 && glibcPath . length > 0 ) {
69+ getLogger ( 'amazonqLsp' ) . info ( 'GLIBC patching environment variables detected' )
70+ return true
71+ }
72+
73+ // No environment variables, no patching needed
74+ return false
6175}
6276
6377export async function startLanguageServer (
@@ -82,9 +96,24 @@ export async function startLanguageServer(
8296 const traceServerEnabled = Settings . instance . isSet ( `${ clientId } .trace.server` )
8397 let executable : string [ ] = [ ]
8498 // apply the GLIBC 2.28 path to node js runtime binary
85- if ( isAmazonLinux2 ( ) && hasGlibcPatch ( ) ) {
86- executable = [ glibcLinker , '--library-path' , glibcPath , resourcePaths . node ]
87- getLogger ( 'amazonqLsp' ) . info ( `Patched node runtime with GLIBC to ${ executable } ` )
99+ if ( isSageMaker ( ) ) {
100+ // SageMaker doesn't need GLIBC patching
101+ getLogger ( 'amazonqLsp' ) . info ( 'SageMaker environment detected, skipping GLIBC patching' )
102+ executable = [ resourcePaths . node ]
103+ } else if ( isAmazonLinux2 ( ) && hasGlibcPatch ( ) ) {
104+ // Use environment variables if available (for CDM)
105+ if ( process . env . VSCODE_SERVER_CUSTOM_GLIBC_LINKER && process . env . VSCODE_SERVER_CUSTOM_GLIBC_PATH ) {
106+ executable = [
107+ process . env . VSCODE_SERVER_CUSTOM_GLIBC_LINKER ,
108+ '--library-path' ,
109+ process . env . VSCODE_SERVER_CUSTOM_GLIBC_PATH ,
110+ resourcePaths . node ,
111+ ]
112+ getLogger ( 'amazonqLsp' ) . info ( `Patched node runtime with GLIBC using env vars to ${ executable } ` )
113+ } else {
114+ // No environment variables, use the node executable directly
115+ executable = [ resourcePaths . node ]
116+ }
88117 } else {
89118 executable = [ resourcePaths . node ]
90119 }
0 commit comments