eyaltoledano/claude-task-master · error
Could not determine project root directory
Error message
Could not determine project root directory
What it means
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.
Source
Thrown at scripts/modules/task-manager/research.js:114
includeProjectTree = false,
detailLevel = 'medium',
projectRoot: providedProjectRoot,
tag,
saveToFile = false
} = options;
const {
session,
mcpLog,
commandName = 'research',
outputType = 'cli'
} = context;
const isMCP = !!mcpLog;
// Determine project root
const projectRoot = providedProjectRoot || findProjectRoot();
if (!projectRoot) {
throw new Error('Could not determine project root directory');
}
// Create consistent logger
const logFn = isMCP
? mcpLog
: {
info: (...args) => consoleLog('info', ...args),
warn: (...args) => consoleLog('warn', ...args),
error: (...args) => consoleLog('error', ...args),
debug: (...args) => consoleLog('debug', ...args),
success: (...args) => consoleLog('success', ...args)
};
// Show UI banner for CLI mode
if (outputFormat === 'text') {
console.log(
boxen(chalk.cyan.bold(`🔍 AI Research Query`), {
padding: 1,View on GitHub (pinned to c0c98d367c)
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.
Example fix
// before
await performResearch('find best state lib', {}); // cwd outside project
// after
await performResearch('find best state lib', { projectRoot: process.cwd() });
// or run the CLI from within the project: cd /path/to/project && task-master research "..." Defensive patterns
Strategy: fallback
Validate before calling
const { findProjectRoot } = require('./utils/path-utils');
const projectRoot = providedProjectRoot || findProjectRoot();
if (!projectRoot) {
throw new Error('Run this command from inside your project (needs package.json or .taskmaster)');
}
await performResearch(prompt, { projectRoot }); Type guard
function hasProjectRoot(ctx) {
return typeof ctx?.projectRoot === 'string' && ctx.projectRoot.length > 0;
} Try / catch
try {
await performResearch(prompt, context);
} catch (err) {
if (err.message.includes('Could not determine project root')) {
console.error('cwd = ' + process.cwd() + ' is not a project root. cd into your repo or pass { projectRoot }.');
process.exitCode = 1;
} else throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not determine project root directory
- Could not determine project root directory
- Export API endpoint not configured. Please set TM_PUBLIC_BAS
- Required API key ${envVarName} for provider '${providerName}
- Could not determine project root directory
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/cb12b76514f8df23.
Report an issue: GitHub.