@@ -8,6 +8,7 @@ import '../../extensions';
88import { inject , injectable } from 'inversify' ;
99import * as path from 'path' ;
1010import { Uri } from 'vscode' ;
11+ import { traceInfo , traceVerbose , traceWarn } from '../../../logging' ;
1112
1213import { IComponentAdapter , ICondaService } from '../../../interpreter/contracts' ;
1314import { IPlatformService } from '../../platform/types' ;
@@ -53,28 +54,36 @@ export class CondaActivationCommandProvider implements ITerminalActivationComman
5354 pythonPath : string ,
5455 targetShell : TerminalShellType ,
5556 ) : Promise < string [ ] | undefined > {
57+ traceVerbose ( `Getting conda activation commands for interpreter ${ pythonPath } with shell ${ targetShell } ` ) ;
5658 const envInfo = await this . pyenvs . getCondaEnvironment ( pythonPath ) ;
5759 if ( ! envInfo ) {
60+ traceWarn ( `No conda environment found for interpreter ${ pythonPath } ` ) ;
5861 return undefined ;
5962 }
63+ traceVerbose ( `Found conda environment: ${ JSON . stringify ( envInfo ) } ` ) ;
6064
6165 const condaEnv = envInfo . name . length > 0 ? envInfo . name : envInfo . path ;
6266
6367 // New version.
6468 const interpreterPath = await this . condaService . getInterpreterPathForEnvironment ( envInfo ) ;
69+ traceInfo ( `Using interpreter path: ${ interpreterPath } ` ) ;
6570 const activatePath = await this . condaService . getActivationScriptFromInterpreter ( interpreterPath , envInfo . name ) ;
71+ traceVerbose ( `Got activation script: ${ activatePath ?. path } } with type: ${ activatePath ?. type } ` ) ;
6672 // eslint-disable-next-line camelcase
6773 if ( activatePath ?. path ) {
6874 if (
6975 this . platform . isWindows &&
7076 targetShell !== TerminalShellType . bash &&
7177 targetShell !== TerminalShellType . gitbash
7278 ) {
73- return [ activatePath . path , `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
79+ const commands = [ activatePath . path , `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
80+ traceInfo ( `Using Windows-specific commands: ${ commands . join ( ', ' ) } ` ) ;
81+ return commands ;
7482 }
7583
7684 const condaInfo = await this . condaService . getCondaInfo ( ) ;
7785
86+ traceVerbose ( `Conda shell level: ${ condaInfo ?. conda_shlvl } ` ) ;
7887 if (
7988 activatePath . type !== 'global' ||
8089 // eslint-disable-next-line camelcase
@@ -84,27 +93,36 @@ export class CondaActivationCommandProvider implements ITerminalActivationComman
8493 // activatePath is not the global activate path, or we don't have a shlvl, or it's -1(conda never sourced).
8594 // and we need to source the activate path.
8695 if ( activatePath . path === 'activate' ) {
87- return [
96+ const commands = [
8897 `source ${ activatePath . path } ` ,
8998 `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ,
9099 ] ;
100+ traceInfo ( `Using source activate commands: ${ commands . join ( ', ' ) } ` ) ;
101+ return commands ;
91102 }
92- return [ `source ${ activatePath . path } ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
103+ const command = [ `source ${ activatePath . path } ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
104+ traceInfo ( `Using single source command: ${ command } ` ) ;
105+ return command ;
93106 }
94- return [ `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
107+ const command = [ `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
108+ traceInfo ( `Using direct conda activate command: ${ command } ` ) ;
109+ return command ;
95110 }
96111
97112 switch ( targetShell ) {
98113 case TerminalShellType . powershell :
99114 case TerminalShellType . powershellCore :
115+ traceVerbose ( 'Using PowerShell-specific activation' ) ;
100116 return _getPowershellCommands ( condaEnv ) ;
101117
102118 // TODO: Do we really special-case fish on Windows?
103119 case TerminalShellType . fish :
120+ traceVerbose ( 'Using Fish shell-specific activation' ) ;
104121 return getFishCommands ( condaEnv , await this . condaService . getCondaFile ( ) ) ;
105122
106123 default :
107124 if ( this . platform . isWindows ) {
125+ traceVerbose ( 'Using Windows shell-specific activation fallback option.' ) ;
108126 return this . getWindowsCommands ( condaEnv ) ;
109127 }
110128 return getUnixCommands ( condaEnv , await this . condaService . getCondaFile ( ) ) ;
0 commit comments