{"record":{"id":"cb12b76514f8df23","repo":"eyaltoledano/claude-task-master","slug":"could-not-determine-project-root-directory-cb12b7","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/research.js","lineNumber":114,"sourceCode":"\t\tincludeProjectTree = false,\n\t\tdetailLevel = 'medium',\n\t\tprojectRoot: providedProjectRoot,\n\t\ttag,\n\t\tsaveToFile = false\n\t} = options;\n\n\tconst {\n\t\tsession,\n\t\tmcpLog,\n\t\tcommandName = 'research',\n\t\toutputType = 'cli'\n\t} = context;\n\tconst isMCP = !!mcpLog;\n\n\t// Determine project root\n\tconst projectRoot = providedProjectRoot || findProjectRoot();\n\tif (!projectRoot) {\n\t\tthrow new Error('Could not determine project root directory');\n\t}\n\n\t// Create consistent logger\n\tconst logFn = isMCP\n\t\t? mcpLog\n\t\t: {\n\t\t\t\tinfo: (...args) => consoleLog('info', ...args),\n\t\t\t\twarn: (...args) => consoleLog('warn', ...args),\n\t\t\t\terror: (...args) => consoleLog('error', ...args),\n\t\t\t\tdebug: (...args) => consoleLog('debug', ...args),\n\t\t\t\tsuccess: (...args) => consoleLog('success', ...args)\n\t\t\t};\n\n\t// Show UI banner for CLI mode\n\tif (outputFormat === 'text') {\n\t\tconsole.log(\n\t\t\tboxen(chalk.cyan.bold(`🔍 AI Research Query`), {\n\t\t\t\tpadding: 1,","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/research.js#L96-L132","documentation":"performResearch() needs the project root to locate .taskmaster/config and the tasks file. It resolves the root from context.projectRoot or falls back to findProjectRoot(); if both fail it throws this error. findProjectRoot() typically walks up from the cwd looking for markers like package.json or .taskmaster, so this error means the process cwd is outside any recognizable project.","triggerScenarios":"Calling performResearch() without context.projectRoot while the process working directory has no package.json/.git/.taskmaster ancestor (e.g. running from /tmp or the home directory), or an MCP invocation where neither serverContext.projectRoot nor providedProjectRoot was supplied.","commonSituations":"Running the CLI from outside the repo, invoking research via the MCP server with a client that never sends projectRoot, Docker containers launched with a bare working directory, or CI jobs that cd into a temp dir before calling the tool.","solutions":["cd into your project directory (the one containing package.json or .taskmaster) before running the research command.","Pass an explicit project root: performResearch(prompt, { projectRoot: '/path/to/project' }).","For MCP usage, ensure the MCP server is started from the project root or configured with the project root in its context.","Add a .taskmaster directory (task-master init) so findProjectRoot() has an anchor marker in the repo."],"exampleFix":"// before\nawait performResearch('find best state lib', {}); // cwd outside project\n// after\nawait performResearch('find best state lib', { projectRoot: process.cwd() });\n// or run the CLI from within the project: cd /path/to/project && task-master research \"...\"","handlingStrategy":"fallback","validationCode":"const { findProjectRoot } = require('./utils/path-utils');\nconst projectRoot = providedProjectRoot || findProjectRoot();\nif (!projectRoot) {\n  throw new Error('Run this command from inside your project (needs package.json or .taskmaster)');\n}\nawait performResearch(prompt, { projectRoot });","typeGuard":"function hasProjectRoot(ctx) {\n  return typeof ctx?.projectRoot === 'string' && ctx.projectRoot.length > 0;\n}","tryCatchPattern":"try {\n  await performResearch(prompt, context);\n} catch (err) {\n  if (err.message.includes('Could not determine project root')) {\n    console.error('cwd = ' + process.cwd() + ' is not a project root. cd into your repo or pass { projectRoot }.');\n    process.exitCode = 1;\n  } else throw err;\n}","preventionTips":["Always run task-master commands from the repository root","Explicitly pass context.projectRoot in scripts and MCP integrations","Initialize the project with 'task-master init' so findProjectRoot has a marker","In Docker/CI set WORKDIR to the project directory before invoking tools"],"tags":["project-root","configuration","environment"],"backgroundTag":"missing-project-root","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}