@@ -34,6 +34,29 @@ import { ILogService } from '../../platform/log/common/log.js';
3434import { promiseWithResolvers } from '../../base/common/async.js' ;
3535import { shouldUseEnvironmentVariableCollection } from '../../platform/terminal/common/terminalEnvironment.js' ;
3636
37+ const cheCodeLdLibPrefixes = new Set < string > ( [
38+ '/checode/checode-linux-libc/ubi8/ld_libs' ,
39+ '/checode/checode-linux-libc/ubi9/ld_libs' ,
40+ '/checode/checode-linux-musl/ld_libs'
41+ ] ) ;
42+
43+ function stripCheCodeLdLibraryPath ( environment : platform . IProcessEnvironment ) : void {
44+ const current = environment [ 'LD_LIBRARY_PATH' ] ;
45+ if ( ! current ) {
46+ return ;
47+ }
48+ const filtered = current
49+ . split ( ':' )
50+ . map ( entry => entry . trim ( ) )
51+ . filter ( entry => ! ! entry && ! cheCodeLdLibPrefixes . has ( entry ) )
52+ . join ( ':' ) ;
53+ if ( filtered ) {
54+ environment [ 'LD_LIBRARY_PATH' ] = filtered ;
55+ } else {
56+ delete environment [ 'LD_LIBRARY_PATH' ] ;
57+ }
58+ }
59+
3760class CustomVariableResolver extends AbstractVariableResolverService {
3861 constructor (
3962 env : platform . IProcessEnvironment ,
@@ -208,6 +231,9 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
208231
209232
210233 const baseEnv = await buildUserEnvironment ( args . resolverEnv , ! ! args . shellLaunchConfig . useShellEnvironment , platform . language , this . _environmentService , this . _logService , this . _configurationService ) ;
234+ if ( process . env [ 'CHECODE_STRIP_LD_LIBRARY_PATH_FOR_SHELL_ENV' ] === '1' ) {
235+ stripCheCodeLdLibraryPath ( baseEnv ) ;
236+ }
211237 this . _logService . trace ( 'baseEnv' , baseEnv ) ;
212238
213239 const reviveWorkspaceFolder = ( workspaceData : IWorkspaceFolderData ) : IWorkspaceFolder => {
@@ -240,6 +266,9 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
240266 args . configuration [ 'terminal.integrated.detectLocale' ] ,
241267 baseEnv
242268 ) ;
269+ if ( process . env [ 'CHECODE_STRIP_LD_LIBRARY_PATH_FOR_SHELL_ENV' ] === '1' ) {
270+ stripCheCodeLdLibraryPath ( env ) ;
271+ }
243272
244273 // Apply extension environment variable collections to the environment
245274 if ( shouldUseEnvironmentVariableCollection ( shellLaunchConfig ) ) {
@@ -330,16 +359,7 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
330359 private _getEnvironment ( ) : platform . IProcessEnvironment {
331360 const env : platform . IProcessEnvironment = { ...process . env } ;
332361 if ( process . env [ 'CHECODE_STRIP_LD_LIBRARY_PATH_FOR_SHELL_ENV' ] === '1' ) {
333- const filtered = ( env [ 'LD_LIBRARY_PATH' ] || '' )
334- . split ( ':' )
335- . map ( entry => entry . trim ( ) )
336- . filter ( entry => ! ! entry && entry !== '/checode/checode-linux-libc/ubi8/ld_libs' && entry !== '/checode/checode-linux-libc/ubi9/ld_libs' && entry !== '/checode/checode-linux-musl/ld_libs' )
337- . join ( ':' ) ;
338- if ( filtered ) {
339- env [ 'LD_LIBRARY_PATH' ] = filtered ;
340- } else {
341- delete env [ 'LD_LIBRARY_PATH' ] ;
342- }
362+ stripCheCodeLdLibraryPath ( env ) ;
343363 }
344364 return env ;
345365 }
0 commit comments