eyaltoledano/claude-task-master · error

Command execution error: ${result.error.message}

Error message

Command execution error: ${result.error.message}

What it means

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.

Source

Thrown at mcp-server/src/tools/utils.js:379

			env: { ...process.env, ...(customEnv || {}) }
		};

		// Log the environment being passed (optional, for debugging)
		// log.info(`Spawn options env: ${JSON.stringify(spawnOptions.env)}`);

		// Execute the command using the global task-master CLI or local script
		// Try the global CLI first
		let result = spawnSync('task-master', fullArgs, spawnOptions);

		// If global CLI is not available, try fallback to the local script
		if (result.error && result.error.code === 'ENOENT') {
			log.info('Global task-master not found, falling back to local script');
			// Pass the same spawnOptions (including env) to the fallback
			result = spawnSync('node', ['scripts/dev.js', ...fullArgs], spawnOptions);
		}

		if (result.error) {
			throw new Error(`Command execution error: ${result.error.message}`);
		}

		if (result.status !== 0) {
			// Improve error handling by combining stderr and stdout if stderr is empty
			const errorOutput = result.stderr
				? result.stderr.trim()
				: result.stdout
					? result.stdout.trim()
					: 'Unknown error';
			throw new Error(
				`Command failed with exit code ${result.status}: ${errorOutput}`
			);
		}

		return {
			success: true,
			stdout: result.stdout,
			stderr: result.stderr

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Install the task-master CLI globally (`npm install -g task-master-ai`) or ensure scripts/dev.js exists in the working directory.
  2. Verify `node` is available on PATH inside the server's environment.
  3. Check spawnOptions.env — pass process.env (plus overrides) so PATH resolves.
  4. Inspect the underlying message after the prefix (ENOENT vs EACCES) and fix accordingly (path vs permissions).

Example fix

// before
spawnSync('task-master', fullArgs, { env: { ...custom } }); // ENOENT: PATH lost
// after
spawnSync('task-master', fullArgs, { env: { ...process.env, ...custom } });
Defensive patterns

Strategy: try-catch

Validate before calling

const bin = spawnSync('task-master', ['--version'], { env: { ...process.env } }); if (bin.error) console.warn('task-master CLI unavailable:', bin.error.message);

Type guard

null

Try / catch

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; }

Prevention

When it happens

Trigger: Global `task-master` binary not on PATH (ENOENT); `node` not found; scripts/dev.js missing; spawn blocked by permissions (EACCES) or environment issues.

Common situations: 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.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/f9427e723a75d2ab. Report an issue: GitHub.