{"record":{"id":"4aa4ae55f1cc1ce4","repo":"paperclipai/paperclip","slug":"cannot-remove-the-shared-managed-cli-while-other-i","errorCode":null,"errorMessage":"Cannot remove the shared managed CLI while other instance services are installed: ${otherDefinitions.join(\", \")}. Uninstall those services first.","messagePattern":"Cannot remove the shared managed CLI while other instance services are installed: (.+?)\\. Uninstall those services first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/uninstall.ts","lineNumber":49,"sourceCode":"  const pattern = platform === \"linux\"\n    ? /^paperclipai(?:-.+)?\\.service$/\n    : /^ing\\.paperclip\\.paperclipai(?:\\..+)?\\.plist$/;\n  return fs.readdirSync(directory)\n    .filter((name) => name !== currentName && pattern.test(name))\n    .map((name) => path.join(directory, name));\n}\n\nexport async function uninstallCommand(\n  dependencies: Partial<UninstallDependencies> = {},\n): Promise<void> {\n  const instanceId = resolvePaperclipInstanceId();\n  const detect = dependencies.detectServiceManager ?? detectServiceManager;\n  const platform = dependencies.platform ?? process.platform;\n  const userHomeDir = dependencies.userHomeDir ?? os.homedir();\n  const detection = await detect({ instanceId, platform });\n  const otherDefinitions = otherServiceDefinitions(platform, userHomeDir, instanceId);\n  if (otherDefinitions.length > 0) {\n    throw new Error(`Cannot remove the shared managed CLI while other instance services are installed: ${otherDefinitions.join(\", \")}. Uninstall those services first.`);\n  }\n  if (!detection.supported && platform === \"linux\") {\n    const definitionPath = path.join(\n      userHomeDir,\n      \".config\",\n      \"systemd\",\n      \"user\",\n      systemdServiceName(instanceId),\n    );\n    if (fs.existsSync(definitionPath)) {\n      throw new Error(\n        `Cannot verify or remove the background service: ${detection.reason}. Retry when the service manager is available.`,\n      );\n    }\n  }\n  if (detection.supported) {\n    const status = await detection.manager.status();\n    if (status.installed || status.active) await detection.manager.uninstall();","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/uninstall.ts#L31-L67","documentation":"Thrown by uninstallCommand when other Paperclip background-service definitions (systemd .service files on Linux, launchd .plist files on macOS) for different instance IDs still exist on disk. The shared managed CLI store is a single payload directory shared across all instances, so removing it would break those other still-installed instance services. The error lists the offending definition file paths so the operator knows exactly what to remove first.","triggerScenarios":"Calling `paperclipai uninstall` (uninstallCommand) on a machine that has two or more Paperclip instances registered, where at least one other instance's service file still lives under ~/.config/systemd/user/ (Linux) or ~/Library/LaunchAgents/ (macOS). The otherServiceDefinitions scan finds service files whose names match the paperclipai pattern but differ from the current instance's service name.","commonSituations":"Running multiple isolated Paperclip instances (different PAPERCLIP_HOME / instance IDs) on one host and uninstalling only one. Leftover service files from a partially-failed prior uninstall or from a manually-registered second instance.","solutions":["Uninstall each remaining instance first via its own `paperclipai uninstall` (run with that instance's PAPERCLIP_HOME/instance env), so otherServiceDefinitions returns empty.","Manually delete the listed service definition files (the paths are in the error message), then re-run `paperclipai uninstall`.","Disable/stop the other services first (`systemctl --user stop <name>` / `launchctl unload <plist>`) before removing their definition files."],"exampleFix":"# before: only one instance uninstalled, others still installed\npaperclipai uninstall\n# after: uninstall every instance, then the shared CLI store is freed\nPAPERCLIP_HOME=/home/u/.paperclip-a paperclipai uninstall\nPAPERCLIP_HOME=/home/u/.paperclip-b paperclipai uninstall","handlingStrategy":"validation","validationCode":"// Run before uninstallCommand to detect blocking services\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\n\nfunction listOtherInstanceServices(instanceId: string, platform: NodeJS.Platform = process.platform): string[] {\n  const dir = platform === 'linux'\n    ? path.join(os.homedir(), '.config', 'systemd', 'user')\n    : platform === 'darwin'\n      ? path.join(os.homedir(), 'Library', 'LaunchAgents')\n      : null;\n  if (!dir || !fs.existsSync(dir)) return [];\n  const pattern = platform === 'linux' ? /^paperclipai(?:-.+)?\\.service$/ : /^ing\\.paperclip\\.paperclipai(?:\\..+)?\\.plist$/;\n  return fs.readdirSync(dir).filter((n) => pattern.test(n));\n}\n// if (listOtherInstanceServices(instanceId).length > 0) { /* uninstall each first */ }","typeGuard":null,"tryCatchPattern":"try {\n  await uninstallCommand();\n} catch (error) {\n  if (error instanceof Error && error.message.startsWith('Cannot remove the shared managed CLI')) {\n    // parse the listed service files, uninstall each instance, then retry\n    const files = error.message.match(/\\/\\S+\\.(?:service|plist)/g) ?? [];\n    for (const f of files) fs.rmSync(f, { force: true });\n    await uninstallCommand();\n  } else throw error;\n}","preventionTips":["Maintain a single source of truth for which Paperclip instances are installed on each host.","Uninstall instances in reverse order of installation so the shared CLI store is freed last.","Before calling uninstallCommand programmatically, scan the service directory for other paperclipai definitions and uninstall them first."],"tags":["uninstall","multi-instance","service-management","cli"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}