eyaltoledano/claude-task-master · error · Error

projectRoot is required for getGitHubRepoInfo

Error message

projectRoot is required for getGitHubRepoInfo

What it means

getGitHubRepoInfo() shells out to 'gh repo view --json ...' with cwd=projectRoot to read repository metadata. It throws when projectRoot is falsy because the gh command must run inside the repository directory.

Source

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

 */
async function isGhCliAvailable(projectRoot = null) {
	try {
		const options = projectRoot ? { cwd: projectRoot } : {};
		await execAsync('gh auth status', options);
		return true;
	} catch (error) {
		return false;
	}
}

/**
 * Get GitHub repository information using gh CLI
 * @param {string} projectRoot - Directory to check (required)
 * @returns {Promise<Object|null>} Repository info or null if not available
 */
async function getGitHubRepoInfo(projectRoot) {
	if (!projectRoot) {
		throw new Error('projectRoot is required for getGitHubRepoInfo');
	}

	try {
		const { stdout } = await execAsync(
			'gh repo view --json name,owner,defaultBranchRef',
			{ cwd: projectRoot }
		);
		return JSON.parse(stdout);
	} catch (error) {
		return null;
	}
}

/**
 * Sanitize branch name to be a valid tag name
 * @param {string} branchName - Git branch name
 * @returns {string} Sanitized tag name
 */

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Pass an explicit root: await getGitHubRepoInfo(process.cwd())
  2. Ensure you are in a project directory or set projectRoot from config before calling
  3. Fix the caller (repoInfo wrapper) to forward projectRoot
  4. Note: even with a valid root, a null result means gh CLI is unavailable — check isGhCliAvailable separately

Example fix

// before
const info = await getGitHubRepoInfo();
// after
const info = projectRoot ? await getGitHubRepoInfo(projectRoot) : null;
Defensive patterns

Strategy: validation

Validate before calling

if (!projectRoot) {
  throw new TypeError('getGitHubRepoInfo requires a projectRoot');
}
const info = await getGitHubRepoInfo(projectRoot);

Type guard

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

Try / catch

try {
  const info = await getGitHubRepoInfo(projectRoot);
} catch (err) {
  if (err.message.includes('projectRoot is required')) {
    return null;
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling getGitHubRepoInfo() with a missing/empty projectRoot argument, typically from the 'repoInfo' helper whose caller did not supply a root.

Common situations: Fetching GitHub metadata (default branch, owner) in commands that also rely on gh CLI; projectRoot undefined because the command ran outside a Task Master project; argument order mistakes when wrapping the helper.

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/833f3151f9708910. Report an issue: GitHub.