{"record":{"id":"f318fd11beaf922f","repo":"google-gemini/gemini-cli","slug":"could-not-install-extension-because-the-current-wo","errorCode":null,"errorMessage":"Could not install extension because the current workspace at ${this.workspaceDir} is not trusted.","messagePattern":"Could not install extension because the current workspace at (.+?) is not trusted\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/config/extension-manager.ts","lineNumber":231,"sourceCode":"\n    const isUpdate = !!previousExtensionConfig;\n    let newExtensionConfig: ExtensionConfig | null = null;\n    let localSourcePath: string | undefined;\n    let extension: GeminiCLIExtension | null;\n    try {\n      if (!isWorkspaceTrusted(this.settings).isTrusted) {\n        if (\n          await this.requestConsent(\n            `The current workspace at \"${this.workspaceDir}\" is not trusted. Do you want to trust this workspace to install extensions?`,\n          )\n        ) {\n          const trustedFolders = loadTrustedFolders();\n          await trustedFolders.setValue(\n            this.workspaceDir,\n            TrustLevel.TRUST_FOLDER,\n          );\n        } else {\n          throw new Error(\n            `Could not install extension because the current workspace at ${this.workspaceDir} is not trusted.`,\n          );\n        }\n      }\n      const extensionsDir = ExtensionStorage.getUserExtensionsDir();\n      await fs.promises.mkdir(extensionsDir, { recursive: true });\n\n      if (installMetadata.type === 'local' || installMetadata.type === 'link') {\n        installMetadata.source = path.isAbsolute(installMetadata.source)\n          ? installMetadata.source\n          : path.resolve(this.workspaceDir, installMetadata.source);\n      }\n\n      let tempDir: string | undefined;\n\n      if (\n        installMetadata.type === 'git' ||\n        installMetadata.type === 'github-release'","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/cli/src/config/extension-manager.ts#L213-L249","documentation":"Thrown when the workspace is not in the trusted-folders list and the user declines the interactive consent prompt that would have trusted it. Folder trust is a precondition for installing extensions because extensions can execute hooks and inject tools.","triggerScenarios":"Running an extension install from a freshly-cloned or unfamiliar directory, seeing the consent prompt, and selecting No / Escape; a non-interactive context where `requestConsent` returns false automatically.","commonSituations":"First-time use of a new repo; CI runners where no TTY is attached and consent defaults to decline; switching workspace roots; corporate policy that requires explicit trust per folder.","solutions":["Pre-trust the folder: run Gemini once interactively and accept, or call the trusted-foldors API to add it.","Re-run the install and answer Yes at the consent prompt.","In non-interactive contexts, set `GEMINI_CLI_TRUST_WORKSPACE=true` or pass `--skip-trust` if the policy allows it."],"exampleFix":"// before\n$ gemini extensions install ./ext   # decline prompt\n// after\n$ gemini   # accept trust prompt once, then retry install","handlingStrategy":"validation","validationCode":"const { isTrusted } = isWorkspaceTrusted(settings);\nif (!isTrusted) {\n  const ok = await requestConsent('Trust this workspace for extension install?');\n  if (!ok) throw new Error('Cannot install: workspace not trusted.');\n}","typeGuard":"function workspaceIsTrusted(settings: unknown): boolean {\n  return isWorkspaceTrusted(settings as MergedSettings).isTrusted;\n}","tryCatchPattern":null,"preventionTips":["Pre-trust long-lived workspace roots via the trusted-folders API.","In CI, set `GEMINI_CLI_TRUST_WORKSPACE=true` if policy permits.","Run extension installs from a trusted directory rather than a fresh clone."],"tags":["extensions","security","workspace-trust","consent"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}