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 = out

View on GitHub (pinned to e04ba88819)

Solutions

  1. Do nothing — the engine uses the relocated data dir automatically; this is informational.
  2. 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.
  3. Silence the warning by ensuring the marker file `.cwd-relocation-warning` can be written in the relocated data dir (check disk space and permissions).
  4. 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

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


AI-assisted analysis of rohitg00/agentmemory@e04ba88819 (2026-08-30). Data as JSON: /api/errors/d8f8d1aeabf789e1. Report an issue: GitHub.