{"record":{"id":"a090ef268088c18b","repo":"eyaltoledano/claude-task-master","slug":"could-not-determine-project-root-directory","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/expand-all-tasks.js","lineNumber":49,"sourceCode":"\tnumSubtasks, // Keep this signature, expandTask handles defaults\n\tuseResearch = false,\n\tadditionalContext = '',\n\tforce = false, // Keep force here for the filter logic\n\tcontext = {},\n\toutputFormat = 'text' // Assume text default for CLI\n) {\n\tconst {\n\t\tsession,\n\t\tmcpLog,\n\t\tprojectRoot: providedProjectRoot,\n\t\ttag,\n\t\tcomplexityReportPath\n\t} = context;\n\tconst isMCPCall = !!mcpLog; // Determine if called from MCP\n\n\tconst projectRoot = providedProjectRoot || findProjectRoot();\n\tif (!projectRoot) {\n\t\tthrow new Error('Could not determine project root directory');\n\t}\n\n\t// Use mcpLog if available, otherwise use the default console log wrapper respecting silent mode\n\tconst logger =\n\t\tmcpLog ||\n\t\t(outputFormat === 'json'\n\t\t\t? {\n\t\t\t\t\t// Basic logger for JSON output mode\n\t\t\t\t\tinfo: (msg) => {},\n\t\t\t\t\twarn: (msg) => {},\n\t\t\t\t\terror: (msg) => console.error(`ERROR: ${msg}`), // Still log errors\n\t\t\t\t\tdebug: (msg) => {}\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\t// CLI logger respecting silent mode\n\t\t\t\t\tinfo: (msg) => !isSilentMode() && log('info', msg),\n\t\t\t\t\twarn: (msg) => !isSilentMode() && log('warn', msg),\n\t\t\t\t\terror: (msg) => !isSilentMode() && log('error', msg),","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/expand-all-tasks.js#L31-L67","documentation":"expandAllTasks() needs a project root to locate .taskmaster/config.json and the tasks file. It uses the provided projectRoot from context or falls back to findProjectRoot(); if neither yields a path, it cannot resolve any file paths and throws.","triggerScenarios":"Calling expandAllTasks() programmatically without context.projectRoot while findProjectRoot() returns null — e.g. the current working directory is outside any directory containing .taskmaster (no .taskmaster folder up the tree).","commonSituations":"Running the CLI from a random directory instead of the project root; tests/scripts executing from a temp dir; a renamed or deleted .taskmaster directory; MCP call where projectRoot parameter was omitted.","solutions":["Run the command from your project root (the directory containing .taskmaster) or pass an explicit projectRoot.","Re-run `task-master init` or restore the missing .taskmaster directory.","In programmatic/MCP calls, always supply context.projectRoot explicitly."],"exampleFix":"// before\nawait expandAllTasks({ tasksPath: undefined }); // cwd has no .taskmaster\n// after\nawait expandAllTasks({ projectRoot: '/path/to/my-project', tasksPath: undefined });","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nfunction findRoot(start = process.cwd()) {\n  let dir = start;\n  while (dir !== path.parse(dir).root) {\n    if (fs.existsSync(path.join(dir, '.taskmaster'))) return dir;\n    dir = path.dirname(dir);\n  }\n  return null;\n}\nconst projectRoot = findRoot();\nif (!projectRoot) throw new Error('Run from a directory containing .taskmaster');","typeGuard":"function hasProjectRoot(ctx) {\n  return !!ctx && (typeof ctx.projectRoot === 'string' || findProjectRoot() !== null);\n}","tryCatchPattern":"try {\n  await expandAllTasks(context);\n} catch (err) {\n  if (err.message.includes('Could not determine project root')) {\n    console.error('Run from your project root or pass projectRoot explicitly.');\n  } else throw err;\n}","preventionTips":["Always execute task-master commands from the project root.","Pass projectRoot explicitly in scripts, tests, and MCP calls.","Ensure the .taskmaster directory exists (task-master init)."],"tags":["project-root","configuration","environment"],"backgroundTag":"project-root-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}