eyaltoledano/claude-task-master · error

Tasks file not found: ${tasksPath}

Error message

Tasks file not found: ${tasksPath}

What it means

In file-storage mode, updateTaskById() checks that the tasks file (tasks.json at the resolved path for the current tag) exists before reading it. This error is thrown when fs.existsSync(tasksPath) is false, i.e., the tasks file has not been created or the path/tag resolves to a nonexistent file.

Source

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

			tag,
			appendMode,
			useResearch,
			metadata,
			isMCP,
			outputFormat,
			report
		});

		// If remote handled it, return the result
		if (remoteResult) {
			return remoteResult;
		}
		// Otherwise fall through to file-based logic below
		// --- End BRIDGE ---

		// For file storage, ensure the tasks file exists
		if (!fs.existsSync(tasksPath))
			throw new Error(`Tasks file not found: ${tasksPath}`);
		// --- End Input Validations ---

		// --- Task Loading and Status Check (Keep existing) ---
		const data = readJSON(tasksPath, projectRoot, tag);
		if (!data || !data.tasks)
			throw new Error(`No valid tasks found in ${tasksPath}.`);
		// File storage requires a strict numeric task ID
		const idStr = String(taskId).trim();
		if (!/^\d+$/.test(idStr)) {
			throw new Error(
				'For file storage, taskId must be a positive integer. ' +
					'Use update-subtask-by-id for IDs like "1.2", or run in API storage for display IDs (e.g., "HAM-123").'
			);
		}
		const numericTaskId = Number(idStr);
		const taskIndex = data.tasks.findIndex((task) => task.id === numericTaskId);
		if (taskIndex === -1) {
			report('error', `Task with ID ${numericTaskId} not found`);

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Run 'task-master init' and 'task-master parse-prd' to generate tasks.json, or create the tasks file
  2. Verify the active tag: run 'task-master list' or check .taskmaster/tasks/ for the tag's file
  3. Confirm the project root is correct so tasksPath resolves to the real file
  4. Restore tasks.json from version control or backup if it was deleted

Example fix

// before
await updateTaskById(5, prompt); // tasks.json missing
// after
import fs from 'fs';
const tasksPath = '.taskmaster/tasks/tasks.json';
if (!fs.existsSync(tasksPath)) {
  await run('task-master parse-prd prd.txt');
}
await updateTaskById(5, prompt);
Defensive patterns

Strategy: validation

Validate before calling

import fs from 'fs';
const tasksPath = '.taskmaster/tasks/tasks.json'; // or resolveTasksPath(tag)
if (!fs.existsSync(tasksPath)) {
  throw new Error(`Initialize first: task-master init && task-master parse-prd prd.txt (missing ${tasksPath})`);
}

Type guard

function tasksFileExists(path) {
  return typeof path === 'string' && fs.existsSync(path);
}

Try / catch

try {
  await updateTaskById(5, prompt);
} catch (err) {
  if (err.message.startsWith('Tasks file not found')) {
    await runInitAndParsePrd(); // create tasks.json, then retry once
  } else throw err;
}

Prevention

When it happens

Trigger: Running update before task-master init / parse-prd ever created tasks.json; a custom or wrong tag resolving to .taskmaster/tasks/<tag>.json that does not exist; wrong project root so the resolved path points nowhere.

Common situations: Fresh clones without initialization; switching to a new tag before creating tasks in it; CI checkouts that exclude .taskmaster; typos in --file or tag options pointing at a missing file.

Related errors


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