can1357/oh-my-pi · error · Error

Git repository not found for isolated task execution.

Error message

Git repository not found for isolated task execution.

What it means

After passing the pure-jj check, getRepoRoot asks the VCS layer for the Git repository root; if no Git repo is detected from the working directory it throws. Isolated tasks need a real Git checkout to create worktrees in, so absence of one is fatal.

Source

Thrown at packages/coding-agent/src/task/worktree.ts:67

	root: RepoBaseline;
	/** Nested git repos (path relative to root.repoRoot). */
	nested: Array<{ relativePath: string; baseline: RepoBaseline }>;
}

export async function getRepoRoot(cwd: string): Promise<string> {
	// Pure-jj check runs first so a jj workspace nested under an unrelated
	// outer Git checkout is rejected at its own root rather than silently
	// mutating the surrounding Git tree behind jj's back.
	if (vcs.isPureJj(cwd)) {
		throw new Error(
			"Isolated task execution requires a Git checkout, but this workspace is pure Jujutsu (`.jj/` without a colocated `.git/`). Run `jj git init --colocate` to add a Git checkout, or set `task.isolation.mode: none` to disable task isolation.",
		);
	}

	const repoRoot = vcs.git(cwd)?.info().repoRoot;
	if (repoRoot) return repoRoot;

	throw new Error("Git repository not found for isolated task execution.");
}

const GIT_NO_INDEX_NULL_PATH = process.platform === "win32" ? "NUL" : "/dev/null";

export function getGitNoIndexNullPath(): string {
	return GIT_NO_INDEX_NULL_PATH;
}

/** Find nested git repositories (non-submodule) under the given root. */
async function discoverNestedRepos(repoRoot: string): Promise<string[]> {
	// Get submodule paths so we can exclude them
	const submodulePaths = new Set(await vcs.requireGit(repoRoot).submodulePaths());

	// Find all .git dirs/files that aren't the root or known submodules
	const result: string[] = [];
	async function walk(dir: string): Promise<void> {
		let entries: Dirent[];
		try {

View on GitHub (pinned to 9690622007)

Solutions

  1. Run the tool from inside a Git repository (cd to your project, or `git init` if it is not one yet)
  2. If the project is jj-based, re-init colocated: `jj git init --colocate`
  3. Check that `.git` exists and is intact at the expected repo root

Example fix

// shell, before
$ cd ~/notes && omp   # not a git repo
// after
$ cd ~/notes && git init && omp
Defensive patterns

Strategy: validation

Validate before calling

import * as fs from "node:fs";
import * as path from "node:path";
function insideGitRepo(dir: string): boolean {
	let cur = path.resolve(dir);
	while (true) {
		if (fs.existsSync(path.join(cur, ".git"))) return true;
		const parent = path.dirname(cur);
		if (parent === cur) return false;
		cur = parent;
	}
}

Try / catch

try {
	const root = await getRepoRoot(cwd);
} catch (err) {
	if ((err as Error).message.includes("Git repository not found")) {
		throw new Error(`Isolate tasks: ${cwd} is not a git checkout`);
	}
	throw err;
}

Prevention

When it happens

Trigger: Calling getRepoRoot/repoRoot from a directory that is neither inside a Git repository nor a pure-jj workspace — e.g. a plain folder, a Mercurial repo, or `$GIT_DIR`/env misconfiguration making `vcs.git(cwd)?.info().repoRoot` return undefined.

Common situations: Running omp with task isolation enabled outside any repo (home dir, temp dir, bare folder); running inside a repo whose `.git` file/dir is corrupted or removed; SVN/Mercurial-only projects.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/30cbebea73fce299. Report an issue: GitHub.