rohitg00/agentmemory · warning
Default data dir ${dataDirResolution.relocatedFrom} is insid
Error message
Default data dir ${dataDirResolution.relocatedFrom} is inside a git worktree; using ${dataDirResolution.dataDir} instead. What it means
agentmemory resolves its default data directory at CLI startup. If the default location (project-local data dir) sits inside a git worktree, the CLI refuses to store state there and relocates the data dir, printing this warning once per relocated location via warnIfRelocatedDataDir. A marker file (.cwd-relocation-warning) suppresses repeat warnings. It is purely informational — the engine continues with the relocated path.
Source
Thrown at src/cli.ts:495
join(process.cwd(), "iii-config.yaml"),
join(homedir(), ".agentmemory", "iii-config.yaml"),
join(__dirname, "iii-config.yaml"),
join(__dirname, "..", "iii-config.yaml"),
];
for (const c of candidates) {
if (existsSync(c)) return resolve(c);
}
return "";
}
function warnIfRelocatedDataDir(): void {
if (!dataDirResolution.relocatedFrom) return;
try {
mkdirSync(dataDirResolution.dataDir, { recursive: true });
const marker = join(dataDirResolution.dataDir, ".cwd-relocation-warning");
if (existsSync(marker)) return;
p.log.warn(
`Default data dir ${dataDirResolution.relocatedFrom} is inside a git worktree; using ${dataDirResolution.dataDir} instead.`,
);
writeFileSync(marker, new Date().toISOString());
} catch {
p.log.warn(
`Default data dir ${dataDirResolution.relocatedFrom} is inside a git worktree; using ${dataDirResolution.dataDir} instead.`,
);
}
}
function whichBinary(name: string): string | null {
const cmd = IS_WINDOWS ? "where" : "which";
try {
const out = execFileSync(cmd, [name], {
encoding: "utf-8",
stdio: ["ignore", "pipe", "pipe"],
});
const first = outView on GitHub (pinned to e04ba88819)
Solutions
- Do nothing — the engine uses the relocated data dir automatically; this is informational.
- If you want state co-located anyway, set the data dir explicitly via the AGENTMEMORY data-dir environment/CLI option to a path outside the worktree.
- Silence the warning by ensuring the marker file `.cwd-relocation-warning` can be written in the relocated data dir (check disk space and permissions).
- Remove the git worktree and use a normal clone if project-local state is required.
Example fix
// before (run inside a worktree, data dir relocated) $ agentmemory start // after (explicit data dir outside worktree) $ AGENTMEMORY_DATA_DIR=~/.agentmemory/data agentmemory start
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from "node:fs";
// detect a git worktree before starting the engine
const insideWorktree =
existsSync(".git") === false ||
require("node:fs").readFileSync(".git", "utf8").includes("gitdir:");
if (insideWorktree) {
process.env.AGENTMEMORY_DATA_DIR ??= "~/.agentmemory/data"; // relocate proactively
} Type guard
function isInGitWorktree(dir: string): boolean {
const gitPath = join(dir, ".git");
try {
return statSync(gitPath).isFile() && readFileSync(gitPath, "utf8").startsWith("gitdir:");
} catch { return false; }
} Prevention
- Set the data-dir env/option explicitly when working in worktrees.
- Check for a .git file (not directory) — the hallmark of a worktree — before starting.
- Keep the marker file intact in the relocated dir to silence repeats.
- Prefer normal clones or explicit data dirs in CI.
When it happens
Trigger: Running any `agentmemory` CLI command (via startEngine → warnIfRelocatedDataDir) from a working directory whose default data dir resolves to a path inside a git worktree (a directory created by `git worktree add`), when no prior marker file exists or the marker write/creation threw.
Common situations: Developers checking out the repo with `git worktree add` for parallel branches; CI runners that clone via worktrees; monorepo setups using worktrees; first run in a fresh worktree before the marker file exists.
Related errors
- agentmemory: could not locate bundled plugin/ directory (sea
- ${adapter.displayName}: guideline not written (${gerr instan
- POST ${url} failed: ${res.status} ${res.statusText}${suffix}
- observe failed for ${obs.toolName}: ${res.status} ${res.stat
- EEXIST
AI-assisted analysis of rohitg00/agentmemory@e04ba88819 (2026-08-30).
Data as JSON: /api/errors/d8f8d1aeabf789e1.
Report an issue: GitHub.