eyaltoledano/claude-task-master · error · Error

projectRoot is required for isGitRepositoryRoot

Error message

projectRoot is required for isGitRepositoryRoot

What it means

isGitRepositoryRoot() checks whether projectRoot is exactly the git repository top-level directory by comparing getGitRepositoryRoot()'s result to projectRoot. It throws when projectRoot is falsy, since it delegates to getGitRepositoryRoot which requires it.

Source

Thrown at scripts/modules/utils/git-utils.js:206

	try {
		const { stdout } = await execAsync('git rev-parse --show-toplevel', {
			cwd: projectRoot
		});
		return stdout.trim();
	} catch (error) {
		return null;
	}
}

/**
 * Check if specified directory is the git repository root
 * @param {string} projectRoot - Directory to check (required)
 * @returns {Promise<boolean>} True if directory is git root
 */
async function isGitRepositoryRoot(projectRoot) {
	if (!projectRoot) {
		throw new Error('projectRoot is required for isGitRepositoryRoot');
	}

	try {
		const gitRoot = await getGitRepositoryRoot(projectRoot);
		return gitRoot && path.resolve(gitRoot) === path.resolve(projectRoot);
	} catch (error) {
		return false;
	}
}

/**
 * Get the default branch name for the repository
 * @param {string} projectRoot - Directory to check (required)
 * @returns {Promise<string|null>} Default branch name or null
 */
async function getDefaultBranch(projectRoot) {
	if (!projectRoot) {
		throw new Error('projectRoot is required for getDefaultBranch');

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Pass an explicit directory: await isGitRepositoryRoot(process.cwd())
  2. Validate projectRoot before calling and default to process.cwd()
  3. Fix the caller that yields an empty value
  4. Wrap in try-catch: the helper also propagates errors from getGitRepositoryRoot

Example fix

// before
const isRoot = await isGitRepositoryRoot(projectRoot);
// after
const isRoot = projectRoot ? await isGitRepositoryRoot(projectRoot) : false;
Defensive patterns

Strategy: validation

Validate before calling

if (!projectRoot) {
  throw new TypeError('isGitRepositoryRoot requires a directory to check');
}
const isRoot = await isGitRepositoryRoot(projectRoot);

Type guard

function hasProjectRoot(p) {
  return typeof p === 'string' && p.trim().length > 0;
}

Try / catch

try {
  const isRoot = await isGitRepositoryRoot(projectRoot);
} catch (err) {
  if (err.message.includes('projectRoot is required')) {
    return false;
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling isGitRepositoryRoot() with no argument, or with an empty/undefined projectRoot that failed to resolve upstream.

Common situations: Deciding whether to write .taskmaster/ at the current location; running from a subdirectory vs repo root; projectRoot not passed through from the CLI command context.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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