{"record":{"id":"63691c13f5010ce5","repo":"can1357/oh-my-pi","slug":"plugin-pluginid-is-installed-in-both-user-and-63691c","errorCode":null,"errorMessage":"Plugin \"${pluginId}\" is installed in both user and project scope. Use --scope user or --scope project to specify which to modify.","messagePattern":"Plugin \"(.+?)\" is installed in both user and project scope\\. Use --scope user or --scope project to specify which to modify\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/extensibility/plugins/marketplace/manager.ts","lineNumber":568,"sourceCode":"\t\t}\n\t\treturn results;\n\t}\n\n\tasync setPluginEnabled(pluginId: string, enabled: boolean, scope?: \"user\" | \"project\"): Promise<void> {\n\t\tconst { userEntries, projectEntries, userReg, projectReg } = await this.#findInBothRegistries(pluginId);\n\n\t\tconst inUser = userEntries && userEntries.length > 0;\n\t\tconst inProject = projectEntries && projectEntries.length > 0;\n\n\t\tif (!inUser && !inProject) {\n\t\t\tthrow new Error(`Plugin \"${pluginId}\" is not installed`);\n\t\t}\n\n\t\t// Disambiguation: if installed in both scopes and no explicit scope, require one.\n\t\tlet targetScope: \"user\" | \"project\";\n\t\tif (inUser && inProject) {\n\t\t\tif (!scope) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \"${pluginId}\" is installed in both user and project scope. Use --scope user or --scope project to specify which to modify.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\ttargetScope = scope;\n\t\t} else if (inProject) {\n\t\t\tif (scope === \"user\") {\n\t\t\t\tthrow new Error(`Plugin \"${pluginId}\" is not installed in user scope`);\n\t\t\t}\n\t\t\ttargetScope = \"project\";\n\t\t} else {\n\t\t\tif (scope === \"project\") {\n\t\t\t\tthrow new Error(`Plugin \"${pluginId}\" is not installed in project scope`);\n\t\t\t}\n\t\t\ttargetScope = \"user\";\n\t\t}\n\n\t\tconst reg = targetScope === \"project\" ? projectReg : userReg;\n\t\tconst entries = targetScope === \"project\" ? projectEntries! : userEntries!;","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/extensibility/plugins/marketplace/manager.ts#L550-L586","documentation":"When a plugin id exists in BOTH the user-scope and project-scope installed-plugins registries, setPluginEnabled() refuses to guess which copy the caller means and throws this error, asking for an explicit scope. This avoids toggling enablement on the wrong installation — the project copy normally shadows the user copy, and the two have independent enabled flags.","triggerScenarios":"Calling `setPluginEnabled(pluginId, enabled)` with the `scope` argument omitted (or the CLI omitting --scope) while `#findInBothRegistries(pluginId)` returns non-empty entries for both userEntries and projectEntries.","commonSituations":"A plugin was originally installed at user scope and later also installed into a project (or vice versa); a team repo committed a project-scope plugin registry for something the developer already had globally; scripted automation that never passes --scope starts failing after a second-scope install.","solutions":["Pass an explicit scope: `--scope project` to modify the project-local copy (usually what shadows at runtime), or `--scope user` for the global one.","In code, call setPluginEnabled(id, enabled, \"project\") or (id, enabled, \"user\") instead of omitting the third argument.","If only one copy is needed, uninstall the redundant scope first so future scope-less calls resolve unambiguously."],"exampleFix":"// before\nawait manager.setPluginEnabled(\"formatter@team\", false);\n// after\nawait manager.setPluginEnabled(\"formatter@team\", false, \"project\");","handlingStrategy":"validation","validationCode":"const installed = await manager.listInstalledPlugins();\nconst copies = installed.filter(p => p.id === pluginId);\nif (copies.length > 1 && !scope) {\n  scope = \"project\"; // project copy shadows user copy; pick explicitly\n}","typeGuard":"function needsExplicitScope(copies: { scope: \"user\" | \"project\" }[]): boolean {\n  return copies.some(c => c.scope === \"user\") && copies.some(c => c.scope === \"project\");\n}","tryCatchPattern":"try {\n  await manager.setPluginEnabled(pluginId, enabled);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"installed in both user and project scope\")) {\n    await manager.setPluginEnabled(pluginId, enabled, \"project\");\n  } else throw err;\n}","preventionTips":["Always pass an explicit scope in scripts; reserve scope-less calls for interactive use.","Prefer \"project\" when both copies exist, since the enabled project copy shadows the user one.","Avoid installing the same plugin at both scopes; uninstall the redundant copy."],"tags":["plugins","marketplace","ambiguous-scope","configuration"],"backgroundTag":"ambiguous-plugin-scope","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}