@@ -38,6 +38,7 @@ import {
38
38
isAmazonLinux2 ,
39
39
getClientId ,
40
40
extensionVersion ,
41
+ isSageMaker ,
41
42
} from 'aws-core-vscode/shared'
42
43
import { processUtils } from 'aws-core-vscode/shared'
43
44
import { activate } from './chat/activation'
@@ -53,11 +54,24 @@ import { InlineChatTutorialAnnotation } from '../app/inline/tutorials/inlineChat
53
54
const localize = nls . loadMessageBundle ( )
54
55
const logger = getLogger ( 'amazonqLsp.lspClient' )
55
56
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
-
59
57
export 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
61
75
}
62
76
63
77
export async function startLanguageServer (
@@ -82,9 +96,24 @@ export async function startLanguageServer(
82
96
const traceServerEnabled = Settings . instance . isSet ( `${ clientId } .trace.server` )
83
97
let executable : string [ ] = [ ]
84
98
// 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
+ }
88
117
} else {
89
118
executable = [ resourcePaths . node ]
90
119
}
0 commit comments