eyaltoledano/claude-task-master · error

Could not determine project root directory

Error message

Could not determine project root directory

What it means

After argument validation, the function resolves the project root via findProjectRoot() unless one was provided. If neither yields a root (no .taskmaster/tasks.json/markers found up the directory tree), it throws.

Source

Thrown at scripts/modules/task-manager/update-subtask-by-id.js:92

		report('info', `Updating subtask ${subtaskId} with prompt: "${prompt}"`);

		// Basic validation - ID must be present
		if (!subtaskId || typeof subtaskId !== 'string') {
			throw new Error('Subtask ID cannot be empty.');
		}
		// Allow metadata-only updates (no prompt required if metadata is provided)
		if (
			(!prompt || typeof prompt !== 'string' || prompt.trim() === '') &&
			!metadata
		) {
			throw new Error(
				'Prompt cannot be empty unless metadata is provided. Please provide context for the subtask update or metadata to merge.'
			);
		}

		const projectRoot = providedProjectRoot || findProjectRoot();
		if (!projectRoot) {
			throw new Error('Could not determine project root directory');
		}

		// --- BRIDGE: Try remote update first (API storage) ---
		// In API storage, subtask IDs like "HAM-2611" are just regular task IDs
		// So update-subtask and update-task work identically
		const remoteResult = await tryUpdateViaRemote({
			taskId: subtaskId,
			prompt,
			projectRoot,
			tag,
			appendMode: true, // Subtask updates are always append mode
			useResearch,
			metadata,
			isMCP,
			outputFormat,
			report
		});

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Pass projectRoot explicitly in options/context
  2. Run the command from inside the project directory that contains .taskmaster
  3. Run 'task-master init' to create the project markers

Example fix

// before
await updateSubtaskById('5.2', prompt, {}); // cwd has no .taskmaster
// after
await updateSubtaskById('5.2', prompt, { projectRoot: '/path/to/project' });
Defensive patterns

Strategy: fallback

Validate before calling

const projectRoot = providedProjectRoot || findProjectRoot();
if (!projectRoot) {
  throw new Error('No task-master project found from cwd; pass projectRoot');
}

Type guard

null

Try / catch

try {
  await updateSubtaskById(subtaskId, prompt, options);
} catch (err) {
  if (err.message === 'Could not determine project root directory') {
    await updateSubtaskById(subtaskId, prompt, { ...options, projectRoot: process.env.TM_PROJECT_ROOT });
  } else throw err;
}

Prevention

When it happens

Trigger: Running from a directory outside any task-master project without passing projectRoot; findProjectRoot() failing because the .taskmaster directory is missing or the process cwd is outside the repo.

Common situations: MCP servers launched with a cwd that is not the project, scripts run from /tmp or the home directory, repos where task-master init was never run.

Related errors


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