@@ -9,10 +9,10 @@ import {
99 WorkspaceFolder ,
1010} from 'vscode' ;
1111import { PythonEnvironment , PythonTaskExecutionOptions } from '../../api' ;
12- import { traceInfo } from '../../common/logging' ;
12+ import { traceInfo , traceWarn } from '../../common/logging' ;
1313import { executeTask } from '../../common/tasks.apis' ;
1414import { getWorkspaceFolder } from '../../common/workspace.apis' ;
15- import { quoteArg } from './execUtils' ;
15+ import { quoteStringIfNecessary } from './execUtils' ;
1616
1717function getWorkspaceFolderOrDefault ( uri ?: Uri ) : WorkspaceFolder | TaskScope {
1818 const workspace = uri ? getWorkspaceFolder ( uri ) : undefined ;
@@ -26,8 +26,14 @@ export async function runAsTask(
2626) : Promise < TaskExecution > {
2727 const workspace : WorkspaceFolder | TaskScope = getWorkspaceFolderOrDefault ( options . project ?. uri ) ;
2828
29- let executable = environment . execInfo ?. activatedRun ?. executable ?? environment . execInfo ?. run . executable ?? 'python' ;
30- executable = quoteArg ( executable ) ;
29+ let executable = environment . execInfo ?. activatedRun ?. executable ?? environment . execInfo ?. run . executable ;
30+ if ( ! executable ) {
31+ traceWarn ( 'No Python executable found in environment; falling back to "python".' ) ;
32+ executable = 'python' ;
33+ }
34+ // Check and quote the executable path if necessary
35+ executable = quoteStringIfNecessary ( executable ) ;
36+
3137 const args = environment . execInfo ?. activatedRun ?. args ?? environment . execInfo ?. run . args ?? [ ] ;
3238 const allArgs = [ ...args , ...options . args ] ;
3339 traceInfo ( `Running as task: ${ executable } ${ allArgs . join ( ' ' ) } ` ) ;
0 commit comments