Skip to content

Commit a8d47ec

Browse files
Add glibc version checking for enterprise customers with legacy systems (Exafunction#501)
- Add glibc detection functions using multiple fallback methods (ldd, getconf, libc.so.6) - Check glibc version when portal_url is configured (self-hosted mode) - Use legacy language server version 1.46.0 for enterprise customers with glibc <= 2.27 - Preserve existing behavior when conditions are not met - Include proper logging for debugging and monitoring Implements the same logic as VS Code extension commit 15eec19fe34 Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 272c6e2 commit a8d47ec

File tree

1 file changed

+91
-5
lines changed

1 file changed

+91
-5
lines changed

autoload/codeium/server.vim

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,85 @@ endif
3131

3232
let g:codeium_server_job = v:null
3333

34+
function! s:DetectGlibcVersion() abort
35+
if !has('unix') || has('mac')
36+
return v:null
37+
endif
38+
39+
try
40+
try
41+
let ldd_output = system('ldd --version 2>/dev/null')
42+
if v:shell_error == 0
43+
let match = matchlist(ldd_output, 'ldd (GNU libc) \(\d\+\.\d\+\)')
44+
if !empty(match)
45+
call codeium#log#Info('Detected glibc version via ldd: ' . match[1])
46+
return match[1]
47+
endif
48+
endif
49+
catch
50+
endtry
51+
52+
try
53+
let getconf_output = system('getconf GNU_LIBC_VERSION 2>/dev/null')
54+
if v:shell_error == 0
55+
let match = matchlist(getconf_output, 'glibc \(\d\+\.\d\+\)')
56+
if !empty(match)
57+
call codeium#log#Info('Detected glibc version via getconf: ' . match[1])
58+
return match[1]
59+
endif
60+
endif
61+
catch
62+
endtry
63+
64+
try
65+
let libc_output = system('/lib/x86_64-linux-gnu/libc.so.6 2>/dev/null')
66+
if v:shell_error == 0
67+
let match = matchlist(libc_output, 'GNU C Library.*release version \(\d\+\.\d\+\)')
68+
if !empty(match)
69+
call codeium#log#Info('Detected glibc version via libc.so.6: ' . match[1])
70+
return match[1]
71+
endif
72+
endif
73+
catch
74+
endtry
75+
76+
call codeium#log#Warn('Could not detect glibc version using any method')
77+
return v:null
78+
catch
79+
call codeium#log#Error('Error detecting glibc version: ' . v:exception)
80+
return v:null
81+
endtry
82+
endfunction
83+
84+
function! s:CompareVersions(version1, version2) abort
85+
let parts1 = split(a:version1, '\.')
86+
let parts2 = split(a:version2, '\.')
87+
88+
let major1 = str2nr(parts1[0])
89+
let minor1 = str2nr(parts1[1])
90+
let major2 = str2nr(parts2[0])
91+
let minor2 = str2nr(parts2[1])
92+
93+
if major1 != major2
94+
return major1 < major2 ? -1 : 1
95+
endif
96+
97+
if minor1 != minor2
98+
return minor1 < minor2 ? -1 : 1
99+
endif
100+
101+
return 0
102+
endfunction
103+
104+
function! s:IsGlibcVersionLessOrEqual(target_version) abort
105+
let current_version = s:DetectGlibcVersion()
106+
if current_version is# v:null
107+
return v:false
108+
endif
109+
110+
return s:CompareVersions(current_version, a:target_version) <= 0
111+
endfunction
112+
34113
function! s:OnExit(result, status, on_complete_cb) abort
35114
let did_close = has_key(a:result, 'closed')
36115
if did_close
@@ -188,13 +267,20 @@ function! codeium#server#Start(...) abort
188267

189268
let config = get(g:, 'codeium_server_config', {})
190269
if has_key(config, 'portal_url') && !empty(config.portal_url)
191-
let response = system('curl -sL ' . config.portal_url . '/api/version')
192-
if v:shell_error == '0'
193-
let s:language_server_version = response
270+
let has_old_glibc = s:IsGlibcVersionLessOrEqual('2.27')
271+
if has_old_glibc
272+
call codeium#log#Info('Using legacy language server version 1.46.0 for enterprise customer with glibc <= 2.27')
273+
let s:language_server_version = '1.46.0'
194274
let s:language_server_sha = 'enterprise-' . s:language_server_version
195275
else
196-
call codeium#log#Error('Failed to fetch version from ' . config.portal_url)
197-
call codeium#log#Error(v:shell_error)
276+
let response = system('curl -sL ' . config.portal_url . '/api/version')
277+
if v:shell_error == '0'
278+
let s:language_server_version = response
279+
let s:language_server_sha = 'enterprise-' . s:language_server_version
280+
else
281+
call codeium#log#Error('Failed to fetch version from ' . config.portal_url)
282+
call codeium#log#Error(v:shell_error)
283+
endif
198284
endif
199285
endif
200286

0 commit comments

Comments
 (0)