{"record":{"id":"0198768c4d783795","repo":"thedotmack/claude-mem","slug":"could-not-locate-a-codex-marketplace-root-with-ag","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/services/integrations/CodexCliInstaller.ts","lineNumber":125,"sourceCode":"\nfunction resolvePluginMarketplaceRoot(preferredRoot?: string): string {\n  if (preferredRoot) {\n    return assertCodexMarketplaceRoot(preferredRoot);\n  }\n\n  const candidates = [\n    process.env.CLAUDE_PLUGIN_ROOT,\n    process.env.PLUGIN_ROOT,\n    process.cwd(),\n    path.dirname(fileURLToPath(import.meta.url)),\n  ].filter((value): value is string => Boolean(value));\n\n  for (const candidate of candidates) {\n    const resolved = findAncestorWithCodexMarketplace(candidate);\n    if (resolved && missingMarketplaceFiles(resolved).length === 0) return resolved;\n  }\n\n  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.');\n}\n\nfunction lookupCodexOnWindows(): string | null {\n  let stdout: string;\n  try {\n    stdout = execFileSync('where.exe', ['codex'], {\n      encoding: 'utf-8',\n      stdio: ['ignore', 'pipe', 'ignore'],\n      windowsHide: true,\n    });\n  } catch (error) {\n    const err = error instanceof Error ? error : new Error(String(error));\n    logger.warn('WORKER', 'Failed to locate codex via where; falling back to codex.cmd', { command: 'where codex' }, err);\n    return null;\n  }\n\n  const candidates = stdout\n    .split(/\\r?\\n/)","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/integrations/CodexCliInstaller.ts#L107-L143","documentation":"resolvePluginMarketplaceRoot() walks a list of candidate directories (and their ancestors) looking for one that has both .agents/plugins/marketplace.json and plugin/.codex-plugin/plugin.json. When no candidate resolves to a complete marketplace root, it throws with instructions to run the installer from the package or repo root. This is the fallback error when the Codex install cannot self-locate its marketplace.","triggerScenarios":"marketplaceRoot() -> resolvePluginMarketplaceRoot() is called (no preferredRoot, or the preferred root also failed) and every candidate, including all ancestors via findAncestorWithCodexMarketplace, is missing one or both required marker files.","commonSituations":"Running the CLI from an arbitrary directory (e.g. ~ or a script dir) far from any checkout; invoking from an npm global install where dot-directories were stripped; a fresh clone with .agents/ gitignored; a repo restructured so the marker files moved.","solutions":["cd into the claude-mem package or repo root (the one containing .agents/plugins/marketplace.json) and run npx claude-mem@latest install.","Verify both markers exist: ls .agents/plugins/marketplace.json plugin/.codex-plugin/plugin.json; create/restore them from a complete checkout if absent.","Pass an explicit preferredRoot pointing at the correct marketplace root so the ancestor search is not needed."],"exampleFix":"// before: run from an unrelated directory\nnpx claude-mem@latest install\n// Error: Could not locate a Codex marketplace root...\n\n// after: run from the repo root with the marker files\ncd ~/code/claude-mem && npx claude-mem@latest install","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nimport path from 'path';\nfunction findMarketplaceRoot(start: string): string | null {\n  let dir = path.resolve(start);\n  while (true) {\n    if (existsSync(path.join(dir, '.agents/plugins/marketplace.json')) &&\n        existsSync(path.join(dir, 'plugin/.codex-plugin/plugin.json'))) return dir;\n    const parent = path.dirname(dir);\n    if (parent === dir) return null;\n    dir = parent;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  installCodexPlugin();\n} catch (err) {\n  if (err instanceof Error && err.message.includes('Could not locate a Codex marketplace root')) {\n    console.error('Run npx claude-mem@latest install from the repo root containing .agents/plugins/marketplace.json');\n  } else throw err;\n}","preventionTips":["Execute installs from the directory containing .agents/plugins/marketplace.json.","Do not gitignore .agents/ or plugin/.codex-plugin/ in repos used for installs.","Pass an explicit marketplace root instead of relying on ancestor search in scripts/CI."],"tags":["codex","install","marketplace","missing-files"],"backgroundTag":"directory-not-found","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}