{"record":{"id":"f9427e723a75d2ab","repo":"eyaltoledano/claude-task-master","slug":"command-execution-error-result-error-message","errorCode":null,"errorMessage":"Command execution error: ${result.error.message}","messagePattern":"Command execution error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/tools/utils.js","lineNumber":379,"sourceCode":"\t\t\tenv: { ...process.env, ...(customEnv || {}) }\n\t\t};\n\n\t\t// Log the environment being passed (optional, for debugging)\n\t\t// log.info(`Spawn options env: ${JSON.stringify(spawnOptions.env)}`);\n\n\t\t// Execute the command using the global task-master CLI or local script\n\t\t// Try the global CLI first\n\t\tlet result = spawnSync('task-master', fullArgs, spawnOptions);\n\n\t\t// If global CLI is not available, try fallback to the local script\n\t\tif (result.error && result.error.code === 'ENOENT') {\n\t\t\tlog.info('Global task-master not found, falling back to local script');\n\t\t\t// Pass the same spawnOptions (including env) to the fallback\n\t\t\tresult = spawnSync('node', ['scripts/dev.js', ...fullArgs], spawnOptions);\n\t\t}\n\n\t\tif (result.error) {\n\t\t\tthrow new Error(`Command execution error: ${result.error.message}`);\n\t\t}\n\n\t\tif (result.status !== 0) {\n\t\t\t// Improve error handling by combining stderr and stdout if stderr is empty\n\t\t\tconst errorOutput = result.stderr\n\t\t\t\t? result.stderr.trim()\n\t\t\t\t: result.stdout\n\t\t\t\t\t? result.stdout.trim()\n\t\t\t\t\t: 'Unknown error';\n\t\t\tthrow new Error(\n\t\t\t\t`Command failed with exit code ${result.status}: ${errorOutput}`\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tstdout: result.stdout,\n\t\t\tstderr: result.stderr","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/tools/utils.js#L361-L397","documentation":"executeTaskMasterCommand spawns the task-master CLI (global binary or local scripts/dev.js) via spawnSync. If spawn itself fails (binary not found, permission denied, etc.), node sets `result.error`, and the function rethrows it wrapped as 'Command execution error: <message>'. This indicates the process could not be launched at all — no exit code exists.","triggerScenarios":"Global `task-master` binary not on PATH (ENOENT); `node` not found; scripts/dev.js missing; spawn blocked by permissions (EACCES) or environment issues.","commonSituations":"Running the MCP server in an environment where the CLI isn't installed globally; Docker/container images without task-master; PATH not propagated through spawnOptions.env.","solutions":["Install the task-master CLI globally (`npm install -g task-master-ai`) or ensure scripts/dev.js exists in the working directory.","Verify `node` is available on PATH inside the server's environment.","Check spawnOptions.env — pass process.env (plus overrides) so PATH resolves.","Inspect the underlying message after the prefix (ENOENT vs EACCES) and fix accordingly (path vs permissions)."],"exampleFix":"// before\nspawnSync('task-master', fullArgs, { env: { ...custom } }); // ENOENT: PATH lost\n// after\nspawnSync('task-master', fullArgs, { env: { ...process.env, ...custom } });","handlingStrategy":"try-catch","validationCode":"const bin = spawnSync('task-master', ['--version'], { env: { ...process.env } }); if (bin.error) console.warn('task-master CLI unavailable:', bin.error.message);","typeGuard":"null","tryCatchPattern":"try { const r = await executeTaskMasterCommand(args); } catch (e) { if (e.message.startsWith('Command execution error:')) { logger.error('CLI spawn failed', { cause: e.message }); return { success: false, error: 'TASK_MASTER_UNAVAILABLE' }; } throw e; }","preventionTips":["Install task-master globally in every deployment environment","Always pass process.env through spawnOptions so PATH resolves","Check for scripts/dev.js fallback in the working directory","Log result.error details (ENOENT vs EACCES) to distinguish path vs permission issues"],"tags":["process","spawn","cli","enoent"],"backgroundTag":"command-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}