eyaltoledano/claude-task-master · error
projectRoot is required for getGitHubRepoInfo
Error message
projectRoot is required for getGitHubRepoInfo
What it means
getGitHubRepoInfo shells out to 'gh repo view --json name,owner,defaultBranchRef' with cwd=projectRoot. An empty projectRoot cannot be used as the working directory, so the guard throws this error before running the command. Note that this error is distinct from gh CLI being missing — that path returns null instead.
Source
Thrown at packages/tm-core/src/common/utils/git-utils.ts:163
*/
export async function isGhCliAvailable(projectRoot?: string): Promise<boolean> {
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
*/
export async function getGitHubRepoInfo(
projectRoot: string
): Promise<GitHubRepoInfo | null> {
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) as GitHubRepoInfo;
} catch (error) {
return null;
}
}
/**
* Get git repository root directory
*/
export async function getGitRepositoryRoot(
projectRoot: stringView on GitHub (pinned to c0c98d367c)
Solutions
- Pass a non-empty repository path that is inside a GitHub-backed git repo
- Default to process.cwd() when the configured root is missing
- Verify upstream projectRoot resolution before calling; log the value if unsure
- If only default-branch info is needed, handle null return paths and guard the root yourself
Example fix
// before
const info = await getGitHubRepoInfo(opts.projectRoot);
// after
const root = opts.projectRoot || process.cwd();
if (!root) throw new Error('Unable to determine project root');
const info = await getGitHubRepoInfo(root); Defensive patterns
Strategy: validation
Validate before calling
if (!projectRoot || typeof projectRoot !== 'string') {
throw new Error('projectRoot required before querying gh repo info');
}
// additionally confirm gh availability separately; missing gh returns null, not a throw:
const info = await getGitHubRepoInfo(projectRoot); // null when gh absent Type guard
function hasRoot(v: unknown): v is string {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
const info = await getGitHubRepoInfo(projectRoot);
} catch (err) {
if (err instanceof Error && err.message.includes('getGitHubRepoInfo')) {
console.error('projectRoot missing; cannot run gh repo view.');
return null;
}
throw err;
} Prevention
- Distinguish argument errors (throw) from tool-availability (null return) when handling
- Install/authenticate gh CLI separately if repo info is required for your flow
- Default the root to the repo checkout directory in CI and scripts
- Assert projectRoot right after config load, before any git-utils usage
When it happens
Trigger: Calling getGitHubRepoInfo(undefined) or '' — typically from the repoInfo wrapper when projectRoot resolution failed; also when passing an empty root straight from config.
Common situations: Scripts run with an unset project-root flag; monorepo tooling pointing at a root that resolved to empty string; tests that forgot to create/point to a repo fixture.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- projectRoot is required for getGitHubRepoInfo
- projectRoot is required for isGitRepository
- projectRoot is required for getCurrentBranch
- projectRoot is required for getLocalBranches
- projectRoot is required for getRemoteBranches
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/e146380d852e2e25.
Report an issue: GitHub.