paperclipai/paperclip · error · Error

Cannot remove the shared managed CLI while other instance…

Error message

Cannot remove the shared managed CLI while other instance services are installed: ${otherDefinitions.join(", ")}. Uninstall those services first.

What it means

uninstallCommand found other Paperclip instance service definitions still installed alongside the shared managed CLI; removing the shared CLI now would break those services, so the guard demands they be uninstalled first.

Solutions

  1. Uninstall the other instance services first, then remove the shared managed CLI.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cli/src/commands/uninstall.ts:49 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18). Data as JSON: /api/errors/4aa4ae55f1cc1ce4. Report an issue: GitHub.

Appendix: source

Thrown at cli/src/commands/uninstall.ts:49

  const pattern = platform === "linux"
    ? /^paperclipai(?:-.+)?\.service$/
    : /^ing\.paperclip\.paperclipai(?:\..+)?\.plist$/;
  return fs.readdirSync(directory)
    .filter((name) => name !== currentName && pattern.test(name))
    .map((name) => path.join(directory, name));
}

export async function uninstallCommand(
  dependencies: Partial<UninstallDependencies> = {},
): Promise<void> {
  const instanceId = resolvePaperclipInstanceId();
  const detect = dependencies.detectServiceManager ?? detectServiceManager;
  const platform = dependencies.platform ?? process.platform;
  const userHomeDir = dependencies.userHomeDir ?? os.homedir();
  const detection = await detect({ instanceId, platform });
  const otherDefinitions = otherServiceDefinitions(platform, userHomeDir, instanceId);
  if (otherDefinitions.length > 0) {
    throw new Error(`Cannot remove the shared managed CLI while other instance services are installed: ${otherDefinitions.join(", ")}. Uninstall those services first.`);
  }
  if (!detection.supported && platform === "linux") {
    const definitionPath = path.join(
      userHomeDir,
      ".config",
      "systemd",
      "user",
      systemdServiceName(instanceId),
    );
    if (fs.existsSync(definitionPath)) {
      throw new Error(
        `Cannot verify or remove the background service: ${detection.reason}. Retry when the service manager is available.`,
      );
    }
  }
  if (detection.supported) {
    const status = await detection.manager.status();
    if (status.installed || status.active) await detection.manager.uninstall();

View on GitHub (pinned to 120ae5428f)