eyaltoledano/claude-task-master · info

Consider using --project-root to specify the correct project

Error message

Consider using --project-root to specify the correct project location or set TASK_MASTER_PROJECT_ROOT environment variable.

What it means

Companion hint to the previous warning: after defaulting to the current directory because no project markers were found, getProjectRoot advises the user to fix root resolution explicitly via the --project-root flag or the TASK_MASTER_PROJECT_ROOT environment variable. It is informational guidance, not an error.

Source

Thrown at mcp-server/src/tools/utils.js:163

	// 4. Check if the current directory has any indicators of being a task-master project
	const currentDir = process.cwd();
	if (
		PROJECT_MARKERS.some((marker) => {
			const markerPath = path.join(currentDir, marker);
			return fs.existsSync(markerPath);
		})
	) {
		log.info(
			`Using current directory as project root (found project markers): ${currentDir}`
		);
		return currentDir;
	}

	// 5. Default to current working directory but warn the user
	log.warn(
		`No task-master project detected in current directory. Using ${currentDir} as project root.`
	);
	log.warn(
		'Consider using --project-root to specify the correct project location or set TASK_MASTER_PROJECT_ROOT environment variable.'
	);
	return currentDir;
}

/**
 * Extracts and normalizes the project root path from the MCP session object.
 * @param {Object} session - The MCP session object.
 * @param {Object} log - The MCP logger object.
 * @returns {string|null} - The normalized absolute project root path or null if not found/invalid.
 */
function getProjectRootFromSession(session, log) {
	try {
		// Add detailed logging of session structure
		log.info(
			`Session object: ${JSON.stringify({
				hasSession: !!session,
				hasRoots: !!session?.roots,

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Set TASK_MASTER_PROJECT_ROOT in the MCP server's env config.
  2. Pass --project-root when launching CLI tools.
  3. Start the server with cwd inside the task-master project.

Example fix

// before
env: {}
// after
env: { "TASK_MASTER_PROJECT_ROOT": "/abs/path/to/project" }
Defensive patterns

Strategy: fallback

Validate before calling

if (!process.env.TASK_MASTER_PROJECT_ROOT) {
  console.warn('TASK_MASTER_PROJECT_ROOT not set; pass --project-root to avoid cwd fallback.');
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Same conditions as error 723: getProjectRoot found no project markers and fell back to cwd; this second warn line is always emitted immediately after the first.

Common situations: Launching the MCP server outside a project; missing TASK_MASTER_PROJECT_ROOT in docker/CI environments; IDE MCP configs that don't pass env.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/136288a0cb63dbca. Report an issue: GitHub.