thedotmack/claude-mem · error · Error

Could not locate a Codex marketplace root with .agents/plugi

Error message

Could not locate a Codex marketplace root with .agents/plugins/marketplace.json and plugin/.codex-plugin/plugin.json. Run npx claude-mem@latest install from the package or repo root.

What it means

resolvePluginMarketplaceRoot() tries four candidate locations in order (CLAUDE_PLUGIN_ROOT, PLUGIN_ROOT, process.cwd(), and the directory of the installer module) and walks each ancestor for a directory containing .agents/plugins/marketplace.json. If none yields a tree that also passes missingMarketplaceFiles, it throws telling the user to run install from the package/repo root.

Source

Thrown at src/services/integrations/CodexCliInstaller.ts:87

function resolvePluginMarketplaceRoot(preferredRoot?: string): string {
  if (preferredRoot) {
    return assertCodexMarketplaceRoot(preferredRoot);
  }

  const candidates = [
    process.env.CLAUDE_PLUGIN_ROOT,
    process.env.PLUGIN_ROOT,
    process.cwd(),
    path.dirname(fileURLToPath(import.meta.url)),
  ].filter((value): value is string => Boolean(value));

  for (const candidate of candidates) {
    const resolved = findAncestorWithCodexMarketplace(candidate);
    if (resolved && missingMarketplaceFiles(resolved).length === 0) return resolved;
  }

  throw new Error('Could not locate a Codex marketplace root with .agents/plugins/marketplace.json and plugin/.codex-plugin/plugin.json. Run npx claude-mem@latest install from the package or repo root.');
}

function lookupCodexOnWindows(): string | null {
  let stdout: string;
  try {
    stdout = execFileSync('where.exe', ['codex'], {
      encoding: 'utf-8',
      stdio: ['ignore', 'pipe', 'ignore'],
      windowsHide: true,
    });
  } catch (error) {
    const err = error instanceof Error ? error : new Error(String(error));
    logger.warn('WORKER', 'Failed to locate codex via where; falling back to codex.cmd', { command: 'where codex' }, err);
    return null;
  }

  const candidates = stdout
    .split(/\r?\n/)

View on GitHub (pinned to d768ba3643)

Solutions

  1. cd into the claude-mem repo/package root (where .agents/plugins/marketplace.json lives) and re-run the install.
  2. Set CLAUDE_PLUGIN_ROOT (or PLUGIN_ROOT) to the absolute path of a tree containing .agents/plugins/marketplace.json before invoking the installer.
  3. If installing from npm, run `npx claude-mem@latest install` and let it bootstrap the marketplace first; do not run the Codex step in isolation before that.
  4. Confirm the marketplace.json actually exists at the expected path with a quick ls.

Example fix

# before
pwd  # /tmp/some-unrelated-project
npx claude-mem@latest install --codex  # throws

# after
export CLAUDE_PLUGIN_ROOT="$HOME/claude-mem"
npx claude-mem@latest install --codex
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'fs';
import path from 'path';

function resolveCodexRoot(): string | null {
  const candidates = [process.env.CLAUDE_PLUGIN_ROOT, process.env.PLUGIN_ROOT, process.cwd()];
  for (const c of candidates) {
    if (!c) continue;
    let cur = path.resolve(c);
    while (true) {
      if (existsSync(path.join(cur, '.agents', 'plugins', 'marketplace.json'))) return cur;
      const parent = path.dirname(cur);
      if (parent === cur) break;
      cur = parent;
    }
  }
  return null;
}

Type guard

function isMarketplaceRootNotFound(e: unknown): boolean {
  return e instanceof Error && /Could not locate a Codex marketplace root/i.test(e.message);
}

Try / catch

try {
  resolvePluginMarketplaceRoot();
} catch (e) {
  if (e instanceof Error && /Could not locate a Codex marketplace root/i.test(e.message)) {
    console.error('cd into the claude-mem repo/package root, or set CLAUDE_PLUGIN_ROOT, then retry.');
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: The Codex installer is invoked from a working directory that is not inside (and has no ancestor containing) a claude-mem plugin marketplace layout, AND neither CLAUDE_PLUGIN_ROOT nor PLUGIN_ROOT is set to a valid root.

Common situations: Running `npx claude-mem@latest install` from an unrelated project directory; running in a global npm cache location after npx fetch; CI ran install from /tmp or home without cloning; the plugin was never installed so no marketplace.json exists anywhere on disk.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d768ba3643 (2026-08-12). Data as JSON: /api/errors/0198768c4d783795. Report an issue: GitHub.