{"record":{"id":"41962b72c52cfb7e","repo":"eyaltoledano/claude-task-master","slug":"could-not-determine-project-root-directory-41962b","errorCode":null,"errorMessage":"Could not determine project root directory","messagePattern":"Could not determine project root directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-tasks.js","lineNumber":71,"sourceCode":"\t// Flag to easily check which logger type we have\n\tconst isMCP = !!mcpLog;\n\n\tif (isMCP)\n\t\tlogFn.info(`updateTasks called with context: session=${!!session}`);\n\telse logFn('info', `updateTasks called`); // CLI log\n\n\ttry {\n\t\tif (isMCP) logFn.info(`Updating tasks from ID ${fromId}`);\n\t\telse\n\t\t\tlogFn(\n\t\t\t\t'info',\n\t\t\t\t`Updating tasks from ID ${fromId} with prompt: \"${prompt}\"`\n\t\t\t);\n\n\t\t// Determine project root\n\t\tconst projectRoot = providedProjectRoot || findProjectRoot();\n\t\tif (!projectRoot) {\n\t\t\tthrow new Error('Could not determine project root directory');\n\t\t}\n\n\t\t// --- Task Loading/Filtering (Updated to pass projectRoot and tag) ---\n\t\tconst data = readJSON(tasksPath, projectRoot, tag);\n\t\tif (!data || !data.tasks)\n\t\t\tthrow new Error(`No valid tasks found in ${tasksPath}`);\n\t\tconst tasksToUpdate = data.tasks.filter(\n\t\t\t(task) => task.id >= fromId && task.status !== 'done'\n\t\t);\n\t\tif (tasksToUpdate.length === 0) {\n\t\t\tif (isMCP)\n\t\t\t\tlogFn.info(`No tasks to update (ID >= ${fromId} and not 'done').`);\n\t\t\telse\n\t\t\t\tlogFn('info', `No tasks to update (ID >= ${fromId} and not 'done').`);\n\t\t\tif (outputFormat === 'text') console.log(/* yellow message */);\n\t\t\treturn; // Nothing to do\n\t\t}\n\t\t// --- End Task Loading/Filtering ---","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-tasks.js#L53-L89","documentation":"updateTasks resolves the project root (explicit argument or findProjectRoot()) before reading tasks.json. If neither yields a root, it throws this error because all subsequent file operations depend on it.","triggerScenarios":"Calling updateTasks via API/MCP with providedProjectRoot undefined while findProjectRoot() cannot locate a .taskmaster directory (or any ancestor marker) up the directory tree.","commonSituations":"Running the tool outside a taskmaster-initialized project, calling the programmatic API without passing projectRoot from a non-CLI host process, or working from a directory whose ancestors lack .taskmaster/config markers.","solutions":["Run 'task-master init' in the project directory (or cd into the initialized project)","Pass an explicit projectRoot option to updateTasks when invoking programmatically","Verify findProjectRoot's detection marker exists (e.g. .taskmaster/ folder) in the current directory or an ancestor"],"exampleFix":"// before\nawait updateTasks(prompt, fromId);\n// after\nawait updateTasks(prompt, fromId, { projectRoot: '/path/to/project' });","handlingStrategy":"validation","validationCode":"import { findProjectRoot } from '.../utils.js';\nconst projectRoot = findProjectRoot();\nif (!projectRoot) throw new Error('Not inside a task-master project; run task-master init');","typeGuard":null,"tryCatchPattern":"try {\n  await updateTasks(...);\n} catch (e) {\n  if (e.message === 'Could not determine project root directory') {\n    // cd into project or init task-master\n  } else throw e;\n}","preventionTips":["Run task-master from inside an initialized project","Pass projectRoot explicitly in programmatic/MCP usage","Verify .taskmaster/ exists before calling task-manager functions","Don't rely on cwd in wrapper scripts; resolve root first"],"tags":["configuration","project-root","environment"],"backgroundTag":"project-root-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}