eyaltoledano/claude-task-master · error
Project path is required
Error message
Project path is required
What it means
Plain Error thrown by the GitAdapter constructor when projectPath is falsy (empty string, undefined cast to string, null, ''). The adapter validates its required inputs up front before touching git. It is a programmer-input error, not a git state problem.
Source
Thrown at packages/tm-core/src/modules/git/adapters/git-adapter.ts:32
*/
export class GitAdapter {
public projectPath: string;
public git: SimpleGit;
/**
* Creates a new GitAdapter instance.
*
* @param {string} projectPath - Absolute path to the project directory
* @throws {Error} If projectPath is invalid or not absolute
*
* @example
* const git = new GitAdapter('/path/to/project');
* await git.ensureGitRepository();
*/
constructor(projectPath: string) {
// Validate project path
if (!projectPath) {
throw new Error('Project path is required');
}
if (!path.isAbsolute(projectPath)) {
throw new Error('Project path must be an absolute path');
}
// Normalize path
this.projectPath = path.normalize(projectPath);
// Initialize simple-git
this.git = simpleGit(this.projectPath);
}
/**
* Checks if the current directory is a git repository.
* Looks for .git directory or file (worktree/submodule).
*
* @returns {Promise<boolean>} True if in a git repositoryView on GitHub (pinned to c0c98d367c)
Solutions
- Pass a non-empty absolute path: new GitAdapter('/abs/path/to/project')
- Use process.cwd() or resolve your project root before constructing the adapter
- Fix the upstream source returning empty (missing config key, unset env var, CLI flag default)
- Add a pre-construction check so the failure is caught at your boundary with better context
Example fix
// before
const git = new GitAdapter(config.projectPath); // '' if missing
// after
const projectPath = config.projectPath || process.cwd();
if (!projectPath) throw new Error('projectPath not configured');
const git = new GitAdapter(projectPath); Defensive patterns
Strategy: validation
Validate before calling
if (typeof projectPath !== 'string' || projectPath.length === 0) {
throw new Error('projectPath must be a non-empty string before creating GitAdapter');
} Type guard
function isNonEmptyString(v: unknown): v is string {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
const git = new GitAdapter(projectPath);
} catch (e) {
if (e.message === 'Project path is required') {
console.error('Configure a project path (config key/env/CLI flag)');
} else throw e;
} Prevention
- Resolve the project path (config → env → cwd fallback) before constructing the adapter
- Use non-empty string validation at your config-loading boundary
- Avoid '' as a default value for path options; use undefined so fallbacks trigger
- Log the resolved path before adapter construction in debugging
When it happens
Trigger: new GitAdapter(''), new GitAdapter(undefined as any), or passing a variable that is empty because an upstream lookup (config value, CLI flag, env var) returned nothing.
Common situations: Constructing the adapter before resolving the project root; a config file missing the project path key; process.cwd() passed as an empty variable due to a refactoring bug; optional CLI args defaulting to '' instead of undefined.
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
- Project path must be an absolute path
- Failed to fetch tasks from any tag. First error: ${failedTag
- ${authCheck.error}
- `Unknown executor type: ${options.type}`
- not a git repository: ${this.projectPath}
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/7e57a8c8b72c35e2.
Report an issue: GitHub.