thedotmack/claude-mem · error · Error
Not in a git repository. Run this from a checked-out repo.
Error message
Not in a git repository. Run this from a checked-out repo.
What it means
Thrown by checkPrerequisites() when `git rev-parse --is-inside-work-tree` exits non-zero or does not print 'true'. The script shells out to git for repository/PR context (and later uses gh which itself assumes a repo), so this is a hard precondition checked before any gh call.
Source
Thrown at scripts/pr-babysit-status.ts:131
const detail = result.stderr || result.stdout || `exit code ${result.exitCode}`;
throw new Error(`gh ${args.join(' ')} failed: ${detail}`);
}
return result.stdout;
}
function parseJson<T>(raw: string, label: string): T {
try {
return JSON.parse(raw) as T;
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
throw new Error(`Could not parse ${label} JSON: ${message}`);
}
}
function checkPrerequisites() {
const git = runCommand(['git', 'rev-parse', '--is-inside-work-tree']);
if (git.exitCode !== 0 || git.stdout.trim() !== 'true') {
throw new Error('Not in a git repository. Run this from a checked-out repo.');
}
const ghVersion = runCommand(['gh', '--version']);
if (ghVersion.exitCode !== 0) {
throw new Error('GitHub CLI is not available. Install gh and try again.');
}
const auth = runCommand(['gh', 'auth', 'status']);
if (auth.exitCode !== 0) {
throw new Error(`GitHub CLI is not authenticated. Run "gh auth login".\n${auth.stderr || auth.stdout}`.trim());
}
}
function targetArgs(prArg?: string): string[] {
return prArg ? [prArg] : [];
}
function fetchPr(prArg?: string): PullRequest {View on GitHub (pinned to d768ba3643)
Solutions
- cd into a checked-out clone of the repository and re-run.
- If git is missing, install it and ensure it is on PATH; verify with `git --version`.
- If you believe you are in a repo, run `git rev-parse --is-inside-work-tree` manually to see what git reports and fix the work tree state.
Defensive patterns
Strategy: validation
Validate before calling
const r = runCommand(['git', 'rev-parse', '--is-inside-work-tree']);
if (r.exitCode !== 0 || r.stdout.trim() !== 'true') {
console.error('Run from inside a git checkout.');
process.exit(1);
} Prevention
- Run the script only from inside a checked-out repository.
- Call checkPrerequisites() at startup so a non-repo cwd fails fast.
- In CI, ensure the checkout step ran before invoking the script.
When it happens
Trigger: Running the script from a directory that is not inside any git work tree (e.g. /tmp, a fresh empty folder). Running inside a bare repo (no work tree). Running inside the .git directory itself where rev-parse behaves oddly. A git binary missing on PATH (runCommand catches and returns exitCode 127).
Common situations: Invoking the script from a CI checkout that wasn't cloned. Running against a tarball export of the source. A workspace where the .git folder was deleted. PATH misconfigured so git isn't found.
Related errors
- GitHub CLI is not available. Install gh and try again.
- GitHub CLI is not authenticated. Run "gh auth login". ${auth
- installPluginDependencies: no package.json at ${targetDir}
- SyncClient requires a non-empty hubUrl (CLAUDE_MEM_CLOUD_SYN
- Every Claude CLI found is too old for claude-mem (each rejec
AI-assisted analysis of thedotmack/claude-mem@d768ba3643 (2026-08-12).
Data as JSON: /api/errors/5790574556537cec.
Report an issue: GitHub.