@@ -18,6 +18,7 @@ import { type SpawnOptions } from 'child_process';
1818import { access , constants } from 'fs/promises' ;
1919import { SERVER_HARNESS_COMMAND } from '../commands/server-harness' ;
2020import { type RuntimeInfo } from './runtime-detector' ;
21+ import { logger } from '@genkit-ai/tools-common/utils' ;
2122
2223/**
2324 * Configuration for spawning a child process
@@ -38,7 +39,11 @@ export interface SpawnConfig {
3839 */
3940export async function validateExecutablePath ( path : string ) : Promise < boolean > {
4041 try {
41- await access ( path , constants . F_OK | constants . X_OK ) ;
42+ // Remove surrounding quotes if present (handle quotation)
43+ const normalizedPath = path . startsWith ( '"' ) && path . endsWith ( '"' )
44+ ? path . slice ( 1 , - 1 )
45+ : path ;
46+ await access ( normalizedPath , constants . F_OK | constants . X_OK ) ;
4247 return true ;
4348 } catch {
4449 return false ;
@@ -91,7 +96,7 @@ export function buildServerHarnessSpawnConfig(
9196 throw new Error ( 'Log path is required' ) ;
9297 }
9398
94- const command = runtime . execPath ;
99+ let command = runtime . execPath ;
95100 let args : string [ ] ;
96101
97102 if ( runtime . type === 'compiled-binary' ) {
@@ -112,6 +117,13 @@ export function buildServerHarnessSpawnConfig(
112117 shell : runtime . platform === 'win32' ,
113118 } ;
114119
120+ // Handles spaces in the command and arguments on Windows
121+ logger . debug ( `Platform: ${ runtime . platform } ` ) ;
122+ if ( runtime . platform === 'win32' ) {
123+ command = `"${ command } "` ;
124+ args = args . map ( ( arg ) => `"${ arg } "` ) ;
125+ }
126+
115127 return {
116128 command,
117129 args,
0 commit comments