thedotmack/claude-mem · warning

Worktree adoption failed for parent repo (continuing)

Error message

Worktree adoption failed for parent repo (continuing)

What it means

The top-level loop calls adoptMergedWorktrees once per unique parent repository, each in its own try/catch. When one repo's adoption throws before or outside the per-branch handling — git worktree enumeration failing, data directory problems, or the source DB refusing to open — this warning records the repoPath and continues with the remaining repos. The run is a partial success; the failed repo simply has no entry in results.

Source

Thrown at src/services/infrastructure/WorktreeAdoption.ts:414

  } finally {
    db?.close();
  }

  if (uniqueParents.size === 0) {
    logger.debug('SYSTEM', 'Worktree adoption found no known parent repos');
    return results;
  }

  for (const repoPath of uniqueParents) {
    try {
      const result = await adoptMergedWorktrees({
        repoPath,
        dataDirectory,
        dryRun: opts.dryRun
      });
      results.push(result);
    } catch (err) {
      logger.warn(
        'SYSTEM',
        'Worktree adoption failed for parent repo (continuing)',
        { repoPath, error: err instanceof Error ? err.message : String(err) }
      );
    }
  }

  return results;
}

View on GitHub (pinned to e2d1df569a)

Solutions

  1. Identify the failed repo from the logged repoPath — the other repos still processed.
  2. Run `git worktree list` manually in that repo to reproduce the underlying failure.
  3. Fix the repo-specific issue (remount, repair .git, correct permissions) and re-run adoption.
  4. Interpret results as partial success: a repo absent from results is the one that was skipped.
Defensive patterns

Strategy: fallback

Validate before calling

// pre-screen each parent repo so the loop never enters a broken one
for (const repoPath of uniqueParents) {
  const ok = spawnSync('git', ['-C', repoPath, 'worktree', 'list'], { encoding: 'utf8' });
  if (ok.status !== 0) skipped.push(repoPath);
}

Try / catch

try {
  results.push(await adoptMergedWorktrees({ repoPath, dataDirectory }));
} catch (err) {
  // one repo failing must not stop the rest — record and continue
  failedRepos.push({ repoPath, error: String(err) });
}

Prevention

When it happens

Trigger: adoptMergedWorktrees(repoPath, dataDirectory, ...) throws: `git worktree list` fails on that repo (corrupt .git, not a repo), the data directory is unwritable, or the worktree's SQLite DB cannot be opened.

Common situations: One repo among several on an unavailable mount or corrupted; mixed clone formats (worktree vs submodule); per-project permission differences; repos with malformed .git files.

Related errors


AI-assisted analysis of thedotmack/claude-mem@e2d1df569a (2026-08-20). Data as JSON: /api/errors/ec3c22b80726e0bf. Report an issue: GitHub.