@@ -66,17 +66,38 @@ export abstract class ModuleInstaller implements IModuleInstaller {
6666 const pythonPath = isResource ( resource ) ? interpreterPath : resource . path ;
6767 const args = internalPython . execModule ( executionInfo . moduleName , executionInfoArgs ) ;
6868 if ( ! interpreter || interpreter . envType !== EnvironmentType . Unknown ) {
69- await this . executeCommand ( shouldExecuteInTerminal , resource , pythonPath , args , token ) ;
69+ await this . executeCommand (
70+ shouldExecuteInTerminal ,
71+ resource ,
72+ pythonPath ,
73+ args ,
74+ token ,
75+ executionInfo . useShell ,
76+ ) ;
7077 } else if ( settings . globalModuleInstallation ) {
7178 const fs = this . serviceContainer . get < IFileSystem > ( IFileSystem ) ;
7279 if ( await fs . isDirReadonly ( path . dirname ( pythonPath ) ) . catch ( ( _err ) => true ) ) {
7380 this . elevatedInstall ( pythonPath , args ) ;
7481 } else {
75- await this . executeCommand ( shouldExecuteInTerminal , resource , pythonPath , args , token ) ;
82+ await this . executeCommand (
83+ shouldExecuteInTerminal ,
84+ resource ,
85+ pythonPath ,
86+ args ,
87+ token ,
88+ executionInfo . useShell ,
89+ ) ;
7690 }
7791 } else if ( name === translateProductToModule ( Product . pip ) ) {
7892 // Pip should always be installed into the specified environment.
79- await this . executeCommand ( shouldExecuteInTerminal , resource , pythonPath , args , token ) ;
93+ await this . executeCommand (
94+ shouldExecuteInTerminal ,
95+ resource ,
96+ pythonPath ,
97+ args ,
98+ token ,
99+ executionInfo . useShell ,
100+ ) ;
80101 } else {
81102 await this . executeCommand (
82103 shouldExecuteInTerminal ,
@@ -173,6 +194,7 @@ export abstract class ModuleInstaller implements IModuleInstaller {
173194 command : string ,
174195 args : string [ ] ,
175196 token ?: CancellationToken ,
197+ useShell ?: boolean ,
176198 ) {
177199 const options : TerminalCreationOptions = { } ;
178200 if ( isResource ( resource ) ) {
@@ -189,7 +211,17 @@ export abstract class ModuleInstaller implements IModuleInstaller {
189211 } else {
190212 const processServiceFactory = this . serviceContainer . get < IProcessServiceFactory > ( IProcessServiceFactory ) ;
191213 const processService = await processServiceFactory . create ( options . resource ) ;
192- await processService . exec ( command , args ) ;
214+ if ( useShell ) {
215+ const argv = [ command , ...args ] ;
216+ // Concat these together to make a set of quoted strings
217+ const quoted = argv . reduce (
218+ ( p , c ) => ( p ? `${ p } ${ c . toCommandArgument ( ) } ` : `${ c . toCommandArgument ( ) } ` ) ,
219+ '' ,
220+ ) ;
221+ await processService . shellExec ( quoted ) ;
222+ } else {
223+ await processService . exec ( command , args ) ;
224+ }
193225 }
194226 }
195227}
0 commit comments