@@ -8,6 +8,7 @@ import '../../extensions';
8
8
import { inject , injectable } from 'inversify' ;
9
9
import * as path from 'path' ;
10
10
import { Uri } from 'vscode' ;
11
+ import { traceInfo , traceVerbose , traceWarn } from '../../../logging' ;
11
12
12
13
import { IComponentAdapter , ICondaService } from '../../../interpreter/contracts' ;
13
14
import { IPlatformService } from '../../platform/types' ;
@@ -53,28 +54,36 @@ export class CondaActivationCommandProvider implements ITerminalActivationComman
53
54
pythonPath : string ,
54
55
targetShell : TerminalShellType ,
55
56
) : Promise < string [ ] | undefined > {
57
+ traceVerbose ( `Getting conda activation commands for interpreter ${ pythonPath } with shell ${ targetShell } ` ) ;
56
58
const envInfo = await this . pyenvs . getCondaEnvironment ( pythonPath ) ;
57
59
if ( ! envInfo ) {
60
+ traceWarn ( `No conda environment found for interpreter ${ pythonPath } ` ) ;
58
61
return undefined ;
59
62
}
63
+ traceVerbose ( `Found conda environment: ${ JSON . stringify ( envInfo ) } ` ) ;
60
64
61
65
const condaEnv = envInfo . name . length > 0 ? envInfo . name : envInfo . path ;
62
66
63
67
// New version.
64
68
const interpreterPath = await this . condaService . getInterpreterPathForEnvironment ( envInfo ) ;
69
+ traceInfo ( `Using interpreter path: ${ interpreterPath } ` ) ;
65
70
const activatePath = await this . condaService . getActivationScriptFromInterpreter ( interpreterPath , envInfo . name ) ;
71
+ traceVerbose ( `Got activation script: ${ activatePath ?. path } } with type: ${ activatePath ?. type } ` ) ;
66
72
// eslint-disable-next-line camelcase
67
73
if ( activatePath ?. path ) {
68
74
if (
69
75
this . platform . isWindows &&
70
76
targetShell !== TerminalShellType . bash &&
71
77
targetShell !== TerminalShellType . gitbash
72
78
) {
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 ;
74
82
}
75
83
76
84
const condaInfo = await this . condaService . getCondaInfo ( ) ;
77
85
86
+ traceVerbose ( `Conda shell level: ${ condaInfo ?. conda_shlvl } ` ) ;
78
87
if (
79
88
activatePath . type !== 'global' ||
80
89
// eslint-disable-next-line camelcase
@@ -84,27 +93,36 @@ export class CondaActivationCommandProvider implements ITerminalActivationComman
84
93
// activatePath is not the global activate path, or we don't have a shlvl, or it's -1(conda never sourced).
85
94
// and we need to source the activate path.
86
95
if ( activatePath . path === 'activate' ) {
87
- return [
96
+ const commands = [
88
97
`source ${ activatePath . path } ` ,
89
98
`conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ,
90
99
] ;
100
+ traceInfo ( `Using source activate commands: ${ commands . join ( ', ' ) } ` ) ;
101
+ return commands ;
91
102
}
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 ;
93
106
}
94
- return [ `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
107
+ const command = [ `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
108
+ traceInfo ( `Using direct conda activate command: ${ command } ` ) ;
109
+ return command ;
95
110
}
96
111
97
112
switch ( targetShell ) {
98
113
case TerminalShellType . powershell :
99
114
case TerminalShellType . powershellCore :
115
+ traceVerbose ( 'Using PowerShell-specific activation' ) ;
100
116
return _getPowershellCommands ( condaEnv ) ;
101
117
102
118
// TODO: Do we really special-case fish on Windows?
103
119
case TerminalShellType . fish :
120
+ traceVerbose ( 'Using Fish shell-specific activation' ) ;
104
121
return getFishCommands ( condaEnv , await this . condaService . getCondaFile ( ) ) ;
105
122
106
123
default :
107
124
if ( this . platform . isWindows ) {
125
+ traceVerbose ( 'Using Windows shell-specific activation fallback option.' ) ;
108
126
return this . getWindowsCommands ( condaEnv ) ;
109
127
}
110
128
return getUnixCommands ( condaEnv , await this . condaService . getCondaFile ( ) ) ;
0 commit comments