{"record":{"id":"cc21b38b26028ba5","repo":"eyaltoledano/claude-task-master","slug":"could-not-determine-project-root-directory-cc21b3","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-task-by-id.js","lineNumber":92,"sourceCode":"\t\t// Note: taskId can be a number (1), string with dot (1.2), or display ID (HAM-123)\n\t\t// So we don't validate it as strictly anymore\n\t\tif (taskId === null || taskId === undefined || String(taskId).trim() === '')\n\t\t\tthrow new Error('Task ID cannot be empty.');\n\n\t\t// Allow metadata-only updates (prompt can be empty if metadata is provided)\n\t\tif (\n\t\t\t(!prompt || typeof prompt !== 'string' || prompt.trim() === '') &&\n\t\t\t!metadata\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t'Prompt cannot be empty unless metadata is provided for update.'\n\t\t\t);\n\t\t}\n\n\t\t// Determine project root first (needed for API key checks)\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\tif (useResearch && !isApiKeySet('perplexity', session)) {\n\t\t\treport(\n\t\t\t\t'warn',\n\t\t\t\t'Perplexity research requested but API key not set. Falling back.'\n\t\t\t);\n\t\t\tif (outputFormat === 'text')\n\t\t\t\tconsole.log(\n\t\t\t\t\tchalk.yellow('Perplexity AI not available. Falling back to main AI.')\n\t\t\t\t);\n\t\t\tuseResearch = false;\n\t\t}\n\n\t\t// --- BRIDGE: Try remote update first (API storage) ---\n\t\tconst remoteResult = await tryUpdateViaRemote({\n\t\t\ttaskId,\n\t\t\tprompt,","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-task-by-id.js#L74-L110","documentation":"updateTaskById() resolves the project root from the providedProjectRoot argument or by calling findProjectRoot() (which walks up looking for .taskmaster / project markers). This error is thrown when neither yields a root, meaning the code cannot locate the Task Master project directory to read tasks.json and configuration.","triggerScenarios":"Calling updateTaskById from a directory outside any Task Master project (no .taskmaster folder up the tree) without passing providedProjectRoot; running from a temp or home directory; passing an invalid providedProjectRoot that is falsy after normalization.","commonSituations":"Executing the CLI from the wrong cwd in scripts/CI; monorepo layouts where the marker folder is deeper than expected; deleting or renaming the .taskmaster directory; Node scripts run with a different working directory than expected.","solutions":["Run the command from within the Task Master project directory (where .taskmaster/ or tasks.json lives)","Pass the correct project root explicitly via providedProjectRoot / --project-root","Reinitialize or restore the project marker (task-master init) if .taskmaster was removed","Check for typos in the provided project root path"],"exampleFix":"// before\nawait updateTaskById(5, prompt); // cwd has no project root\n// after\nawait updateTaskById(5, prompt, { projectRoot: '/path/to/my-taskmaster-project' });","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nfunction resolveProjectRoot(explicit) {\n  const root = explicit || findProjectRoot();\n  if (!root || !fs.existsSync(root)) {\n    throw new Error('Run from a Task Master project or pass --project-root');\n  }\n  return root;\n}","typeGuard":"function hasProjectRoot(root) {\n  return typeof root === 'string' && root.length > 0 && fs.existsSync(root);\n}","tryCatchPattern":"try {\n  await updateTaskById(5, prompt);\n} catch (err) {\n  if (err.message === 'Could not determine project root directory') {\n    console.error('cd into the project or pass projectRoot explicitly');\n  } else throw err;\n}","preventionTips":["Run commands from the directory containing .taskmaster/","Pass projectRoot explicitly in scripts and CI rather than relying on cwd","Keep the .taskmaster marker directory intact in the repo root","In monorepos, resolve the sub-project root before invoking Task Master APIs"],"tags":["configuration","filesystem","project-root","task-management"],"backgroundTag":"project-root-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}