@@ -280,22 +280,32 @@ async function getCondaBatActivationFile(condaPath: string): Promise<string | un
280280 * This function checks for a local 'activate' script in the same directory as the conda executable.
281281 * This script is used for direct conda activation without shell-specific configuration.
282282 */
283+
284+ const knownSourcingScriptCache : string [ ] = [ ] ;
283285export async function getLocalActivationScript ( condaPath : string ) : Promise < string | undefined > {
284- const activatePath = path . join ( path . dirname ( condaPath ) , 'activate' ) ;
285- traceVerbose ( `Checking for local activation script at: ${ activatePath } ` ) ;
286+ const sourcingScript = isWindows ( )
287+ ? path . join ( condaPath , 'Scripts' , 'activate.bat' )
288+ : path . join ( condaPath , 'bin' , 'activate' ) ;
289+ traceVerbose ( `Checking for local activation script at: ${ sourcingScript } ` ) ;
286290
287291 if ( ! condaPath ) {
288292 traceVerbose ( 'No conda path provided, cannot find local activation script' ) ;
289293 return undefined ;
290294 }
291295
296+ if ( knownSourcingScriptCache . includes ( sourcingScript ) ) {
297+ traceVerbose ( `Found local activation script in cache at: ${ sourcingScript } ` ) ;
298+ return sourcingScript ;
299+ }
300+
292301 try {
293- const exists = await fse . pathExists ( activatePath ) ;
302+ const exists = await fse . pathExists ( sourcingScript ) ;
294303 if ( exists ) {
295- traceInfo ( `Found local activation script at: ${ activatePath } ` ) ;
296- return activatePath ;
304+ traceInfo ( `Found local activation script at: ${ sourcingScript } , adding to cache.` ) ;
305+ knownSourcingScriptCache . push ( sourcingScript ) ;
306+ return sourcingScript ;
297307 } else {
298- traceVerbose ( `No local activation script found at: ${ activatePath } ` ) ;
308+ traceVerbose ( `No local activation script found at: ${ sourcingScript } ` ) ;
299309 return undefined ;
300310 }
301311 } catch ( err ) {
0 commit comments