@@ -14,11 +14,6 @@ import { IPlatformService } from '../../platform/types';
14
14
import { IConfigurationService } from '../../types' ;
15
15
import { ITerminalActivationCommandProvider , TerminalShellType } from '../types' ;
16
16
17
- // Version number of conda that requires we call activate with 'conda activate' instead of just 'activate'
18
- const CondaRequiredMajor = 4 ;
19
- const CondaRequiredMinor = 4 ;
20
- const CondaRequiredMinorForPowerShell = 6 ;
21
-
22
17
/**
23
18
* Support conda env activation (in the terminal).
24
19
*/
@@ -65,57 +60,38 @@ export class CondaActivationCommandProvider implements ITerminalActivationComman
65
60
66
61
const condaEnv = envInfo . name . length > 0 ? envInfo . name : envInfo . path ;
67
62
68
- // Algorithm differs based on version
69
- // Old version, just call activate directly.
70
- // New version, call activate from the same path as our python path, then call it again to activate our environment.
71
- // -- note that the 'default' conda location won't allow activate to work for the environment sometimes.
72
- const versionInfo = await this . condaService . getCondaVersion ( ) ;
73
- if ( versionInfo && versionInfo . major >= CondaRequiredMajor ) {
74
- // Conda added support for powershell in 4.6.
63
+ // New version.
64
+ const interpreterPath = await this . condaService . getInterpreterPathForEnvironment ( envInfo ) ;
65
+ const activatePath = await this . condaService . getActivationScriptFromInterpreter ( interpreterPath , envInfo . name ) ;
66
+ // eslint-disable-next-line camelcase
67
+ if ( activatePath ?. path ) {
75
68
if (
76
- versionInfo . minor >= CondaRequiredMinorForPowerShell &&
77
- ( targetShell === TerminalShellType . powershell || targetShell === TerminalShellType . powershellCore )
69
+ this . platform . isWindows &&
70
+ targetShell !== TerminalShellType . bash &&
71
+ targetShell !== TerminalShellType . gitbash
78
72
) {
79
- return _getPowershellCommands ( condaEnv ) ;
73
+ return [ activatePath . path , `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
80
74
}
81
- if ( versionInfo . minor >= CondaRequiredMinor ) {
82
- // New version.
83
- const interpreterPath = await this . condaService . getInterpreterPathForEnvironment ( envInfo ) ;
84
- const activatePath = await this . condaService . getActivationScriptFromInterpreter (
85
- interpreterPath ,
86
- envInfo . name ,
87
- ) ;
75
+
76
+ const condaInfo = await this . condaService . getCondaInfo ( ) ;
77
+
78
+ if (
79
+ activatePath . type !== 'global' ||
88
80
// eslint-disable-next-line camelcase
89
- if ( activatePath ?. path ) {
90
- if (
91
- this . platform . isWindows &&
92
- targetShell !== TerminalShellType . bash &&
93
- targetShell !== TerminalShellType . gitbash
94
- ) {
95
- return [ activatePath . path , `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
96
- }
97
-
98
- const condaInfo = await this . condaService . getCondaInfo ( ) ;
99
-
100
- if (
101
- activatePath . type !== 'global' ||
102
- // eslint-disable-next-line camelcase
103
- condaInfo ?. conda_shlvl === undefined ||
104
- condaInfo . conda_shlvl === - 1
105
- ) {
106
- // activatePath is not the global activate path, or we don't have a shlvl, or it's -1(conda never sourced).
107
- // and we need to source the activate path.
108
- if ( activatePath . path === 'activate' ) {
109
- return [
110
- `source ${ activatePath . path } ` ,
111
- `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ,
112
- ] ;
113
- }
114
- return [ `source ${ activatePath . path } ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
115
- }
116
- return [ `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
81
+ condaInfo ?. conda_shlvl === undefined ||
82
+ condaInfo . conda_shlvl === - 1
83
+ ) {
84
+ // activatePath is not the global activate path, or we don't have a shlvl, or it's -1(conda never sourced).
85
+ // and we need to source the activate path.
86
+ if ( activatePath . path === 'activate' ) {
87
+ return [
88
+ `source ${ activatePath . path } ` ,
89
+ `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ,
90
+ ] ;
117
91
}
92
+ return [ `source ${ activatePath . path } ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
118
93
}
94
+ return [ `conda activate ${ condaEnv . toCommandArgumentForPythonExt ( ) } ` ] ;
119
95
}
120
96
121
97
switch ( targetShell ) {
0 commit comments