eyaltoledano/claude-task-master · error

Project path must be an absolute path

Error message

Project path must be an absolute path

What it means

Plain Error thrown by the GitAdapter constructor when projectPath is provided but not absolute (path.isAbsolute fails, e.g. './myproject' or 'myproject'). The adapter normalizes and stores the path and needs an absolute base for simple-git operations, so relative paths are rejected at construction.

Source

Thrown at packages/tm-core/src/modules/git/adapters/git-adapter.ts:36

	/**
	 * 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 repository
	 *
	 * @example
	 * const isRepo = await git.isGitRepository();
	 * if (!isRepo) {

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Convert to absolute first: path.resolve(projectPath) or path.resolve(process.cwd(), projectPath)
  2. Expand '~' explicitly with os.homedir() before constructing (path.isAbsolute does not expand tilde)
  3. Fix config/CLI layers to store absolute paths
  4. Reorder construction so the adapter is created after the project root is resolved

Example fix

// before
const git = new GitAdapter('~/projects/app'); // throws: not absolute
// after
import * as os from 'os';
const p = config.projectPath.startsWith('~')
  ? path.join(os.homedir(), config.projectPath.slice(1))
  : path.resolve(config.projectPath);
const git = new GitAdapter(p);
Defensive patterns

Strategy: validation

Validate before calling

import * as path from 'path';
if (!path.isAbsolute(projectPath)) {
  projectPath = path.resolve(process.cwd(), projectPath);
}

Type guard

function isAbsolutePath(v: string): boolean {
  return path.isAbsolute(v);
}

Try / catch

try {
  const git = new GitAdapter(projectPath);
} catch (e) {
  if (e.message === 'Project path must be an absolute path') {
    const git = new GitAdapter(path.resolve(projectPath));
  } else throw e;
}

Prevention

When it happens

Trigger: new GitAdapter('./repo'), new GitAdapter('~/project') (tilde is NOT expanded by path.isAbsolute on POSIX), or passing a path built from a relative CLI/config value.

Common situations: Users writing '~/myproject' in config expecting shell-style tilde expansion; passing relative paths from CWD-based tooling; constructing the adapter in a library where the caller's CWD differs from the project directory.

Related errors


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