{"record":{"id":"a093c5ec62445c0c","repo":"mastra-ai/mastra","slug":"plugin-pluginid-is-not-installed-in-scope","errorCode":null,"errorMessage":"Plugin \"${pluginId}\" is not installed in ${scope} scope","messagePattern":"Plugin \"(.+?)\" is not installed in (.+?) scope","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mastracode/sdk/src/plugins/manager.ts","lineNumber":522,"sourceCode":"    url: string,\n    scope: PluginScope,\n    options: Pick<InstallPluginOptions, 'entry' | 'ref' | 'onOutput' | 'signal'> = {},\n  ): Promise<string> {\n    const id = await installGithubPlugin(url, scope, { ...this.options, ...options });\n    // Installing over an existing checkout replaces it at the same path, so the\n    // cached head would make a genuinely different commit stamp as unchanged and\n    // leave the previous signal providers running.\n    this.githubCheckoutHeads.clear();\n    await this.reload();\n    return id;\n  }\n\n  async setEnabled(pluginId: string, scope: PluginScope, enabled: boolean): Promise<void> {\n    const paths = getPluginScopePaths(scope, this.options);\n    const registry = loadPluginRegistry(paths.registryPath);\n    const record = registry.plugins[pluginId];\n    if (!record) {\n      throw new Error(`Plugin \"${pluginId}\" is not installed in ${scope} scope`);\n    }\n    savePluginRegistry(paths.registryPath, setPluginRecord(registry, pluginId, { ...record, enabled }));\n    await this.reload();\n  }\n\n  async setConfigValue(\n    pluginId: string,\n    scope: PluginScope,\n    key: string,\n    value: MastraCodePluginConfigValue,\n  ): Promise<void> {\n    const paths = getPluginScopePaths(scope, this.options);\n    const registry = loadPluginRegistry(paths.registryPath);\n    const record = registry.plugins[pluginId];\n    if (!record) {\n      throw new Error(`Plugin \"${pluginId}\" is not installed in ${scope} scope`);\n    }\n    const config = { ...(record.config ?? {}) };","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/sdk/src/plugins/manager.ts#L504-L540","documentation":"setEnabled toggles a plugin's enabled flag in the registry file for a given scope (e.g. project/user). Before writing, it loads that scope's registry and requires a record for pluginId; if none exists it throws 'Plugin \"<id>\" is not installed in <scope> scope'. The check is scope-specific — a plugin installed at user scope is not visible in the project registry.","triggerScenarios":"Calling manager.setEnabled(pluginId, scope, enabled) where pluginId was never installed in that scope: typo in the plugin id, wrong scope argument (e.g. PluginScope.PROJECT when it is installed at USER scope), enabling a plugin before running install, or the registry file was deleted/reset.","commonSituations":"Scripting enable/disable with an id copied from a different machine's registry; team repo where the plugin is registered in .mastracode user config but the code passes project scope; stale registry after branch switch; hardcoding plugin ids that were renamed in a newer version.","solutions":["Verify the exact pluginId via the plugin list/registry for that scope before calling setEnabled.","Pass the correct scope — check which registry file (project vs user path from getPluginScopePaths) actually contains the plugin.","Install the plugin in the target scope first, then call setEnabled.","Fix typos/case mismatches in the plugin id string."],"exampleFix":"// before\nawait manager.setEnabled('my-plugn', PluginScope.PROJECT, true);\n// after\nconst installed = manager.list().some(p => p.id === 'my-plugin' && p.scope === 'project');\nif (installed) await manager.setEnabled('my-plugin', PluginScope.PROJECT, true);","handlingStrategy":"validation","validationCode":"const installed = await manager.list(); // or read registry.plugins for the scope\nif (!installed.some(p => p.id === pluginId && p.scope === scope)) {\n  throw new Error(`Refusing: plugin \"${pluginId}\" not installed in ${scope} scope`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await manager.setEnabled(pluginId, scope, enabled);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('is not installed in')) {\n    const match = err.message.match(/Plugin \"(.+)\" is not installed in (.+) scope/);\n    console.error(`Check id '${match?.[1]}' and scope '${match?.[2]}'; available: ${await listPluginIds()}`);\n  } else throw err;\n}","preventionTips":["Resolve plugin ids from the registry/list output rather than hardcoding strings.","Always pair scope with how the plugin was installed (user vs project registry paths).","Install-then-configure: run install before any enable/config calls in scripts and CI."],"tags":["plugin","registry","scope-mismatch","state"],"backgroundTag":"plugin-not-installed-in-scope","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}