{"record":{"id":"5597f97de24cd82e","repo":"EveryInc/compound-engineering-plugin","slug":"cannot-switch-to-remote-mode-while-the-local-colle","errorCode":null,"errorMessage":"Cannot switch to remote mode while the local collection is ${collection.kind}","messagePattern":"Cannot switch to remote mode while the local collection is (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/dev/codex-dev.ts","lineNumber":617,"sourceCode":"      `Marketplace ${OFFICIAL_MARKETPLACE} exists with an unexpected source; refusing to replace it`,\n    )\n  }\n  await runCodex(context, runner, [\n    \"plugin\",\n    \"marketplace\",\n    \"upgrade\",\n    OFFICIAL_MARKETPLACE,\n    \"--json\",\n  ])\n}\n\nexport async function switchToRemote(\n  context: CodexDevContext,\n  runner: CommandRunner = new BunCommandRunner(),\n): Promise<CodexDevStatus> {\n  const collection = await inspectLocalCollection(context)\n  if (collection.kind === \"collision\" || collection.kind === \"unrelated\" || collection.kind === \"broken\") {\n    throw new Error(`Cannot switch to remote mode while the local collection is ${collection.kind}`)\n  }\n\n  await ensureOfficialMarketplace(context, runner)\n  const plugins = await listCompoundEngineeringPlugins(context, runner)\n  await removePlugins(\n    context,\n    runner,\n    collection.kind === \"valid\"\n      ? plugins\n      : plugins.filter((entry) => entry.pluginId !== OFFICIAL_PLUGIN_ID),\n  )\n  await runCodex(context, runner, [\"plugin\", \"add\", OFFICIAL_PLUGIN_ID, \"--json\"])\n\n  const installed = await listCompoundEngineeringPlugins(context, runner)\n  if (installed.length !== 1 || !isOfficialMarketplacePlugin(installed[0]!)) {\n    throw new Error(\"Could not verify the official marketplace-backed Compound Engineering plugin\")\n  }\n","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/EveryInc/compound-engineering-plugin/blob/c9c10f8c75412c7232cb2bd663e5fd1cea98d84e/src/dev/codex-dev.ts#L599-L635","documentation":"`switchToRemote()` inspects the local collection (the `$CODEX_HOME/skills/compound-engineering-local` symlink) before switching. If the collection is in a state the tool cannot safely clean up — `collision` (a real file/dir occupies the symlink path), `unrelated` (symlink points somewhere foreign), or `broken` (dangling target) — it refuses and throws, to avoid deleting data it did not create.","triggerScenarios":"Calling `switchToRemote(context, runner)` when `inspectLocalCollection` returns `kind` of `\"collision\"`, `\"unrelated\"`, or `\"broken\"` — e.g. the user replaced the skill symlink with a real directory, pointed it at their own skills, or deleted the target checkout.","commonSituations":"User created `$CODEX_HOME/skills/compound-engineering-local` manually as a folder; target worktree was deleted without running `codex:dev -- remove`; a different tool wrote to the same skills path.","solutions":["Inspect the path `$CODEX_HOME/skills/compound-engineering-local` yourself","If it is safe to delete, remove the offending file/symlink manually, then retry `codex:dev -- remote`","Run `codex:dev -- status` to confirm the collection state is now `absent` before switching","Preserve anything valuable from a `collision` directory before deleting"],"exampleFix":"// before: dangling symlink blocks switch\nrm ~/.codex/skills/compound-engineering-local\nbun run codex:dev -- remote","handlingStrategy":"validation","validationCode":"const collection = await inspectLocalCollection(context)\nif (collection.kind === \"collision\" || collection.kind === \"unrelated\" || collection.kind === \"broken\") {\n  throw new Error(`Resolve the ${collection.kind} local collection at $CODEX_HOME/skills/compound-engineering-local first`)\n}\nawait switchToRemote(context, runner)","typeGuard":"function isCleanCollection(c: LocalCollectionState): boolean {\n  return c.kind === \"absent\" || c.kind === \"valid\"\n}","tryCatchPattern":"try {\n  await switchToRemote(context, runner)\n} catch (error) {\n  if (String(error).includes(\"local collection is\")) {\n    console.error(\"Inspect and clean $CODEX_HOME/skills/compound-engineering-local manually, then retry\")\n  } else throw error\n}","preventionTips":["Never create files/directories at the compound-engineering-local skill path yourself","Always run `codex:dev -- remove` before deleting a linked worktree","Check `codex:dev -- status` before switching modes"],"tags":["codex","local-collection","unsafe-state"],"backgroundTag":"unsafe-local-collection-state","analyzedSha":"c9c10f8c75412c7232cb2bd663e5fd1cea98d84e","analyzedAt":"2026-08-31T15:18:07.959Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}