google-gemini/gemini-cli · error

Installing extension from source "${installMetadata.source}"

Error message

Installing extension from source "${installMetadata.source}" is not allowed by the "allowedExtensions" security setting.

What it means

Thrown when `settings.security.allowedExtensions` is a non-empty array but no pattern in it matches the resolved real path of `installMetadata.source`. The allowlist is opt-in: once you populate it, every extension source must match at least one pattern or the install is refused.

Source

Thrown at packages/cli/src/config/extension-manager.ts:200

    previousExtensionConfig?: ExtensionConfig,
    requestConsentOverride?: (consent: string) => Promise<boolean>,
  ): Promise<GeminiCLIExtension> {
    if ((this.settings.security?.allowedExtensions?.length ?? 0) > 0) {
      const extensionAllowed = this.settings.security?.allowedExtensions.some(
        (pattern) => {
          try {
            return new RegExp(pattern).test(
              getRealPath(installMetadata.source),
            );
          } catch (e) {
            throw new Error(
              `Invalid regex pattern in allowedExtensions setting: "${pattern}. Error: ${getErrorMessage(e)}`,
            );
          }
        },
      );
      if (!extensionAllowed) {
        throw new Error(
          `Installing extension from source "${installMetadata.source}" is not allowed by the "allowedExtensions" security setting.`,
        );
      }
    } else if (
      (installMetadata.type === 'git' ||
        installMetadata.type === 'github-release') &&
      this.settings.security.blockGitExtensions
    ) {
      throw new Error(
        'Installing extensions from remote sources is disallowed by your current settings.',
      );
    }

    const isUpdate = !!previousExtensionConfig;
    let newExtensionConfig: ExtensionConfig | null = null;
    let localSourcePath: string | undefined;
    let extension: GeminiCLIExtension | null;
    try {

View on GitHub (pinned to 5024443c72)

Solutions

  1. Add a regex pattern that matches the source you want to install into `security.allowedExtensions`.
  2. Use a broader prefix pattern such as `^https://github\.com/` if multiple orgs are allowed.
  3. Verify the resolved path with `realpath`/`getRealPath` — relative sources are resolved against `workspaceDir`.

Example fix

// before
{ "security": { "allowedExtensions": ["^https://github\\.com/myorg/"] } }
// after
{ "security": { "allowedExtensions": ["^https://github\\.com/(myorg|trusted-partner)/"] } }
Defensive patterns

Strategy: validation

Validate before calling

function isSourceAllowed(source: string, patterns: RegExp[]): boolean {
  const real = getRealPath(source);
  return patterns.some((re) => re.test(real));
}
const patterns = (settings.security?.allowedExtensions ?? []).map((p) => new RegExp(p));
if (patterns.length > 0 && !isSourceAllowed(installMetadata.source, patterns)) {
  throw new Error(`Source ${installMetadata.source} not in allowedExtensions.`);
}

Type guard

function sourceMatchesAllowed(source: string, patterns: readonly string[]): boolean {
  const real = getRealPath(source);
  return patterns.some((p) => { try { return new RegExp(p).test(real); } catch { return false; } });
}

Prevention

When it happens

Trigger: Attempting to install from a new GitHub org or local path that isn't covered by any of the configured patterns; the allowlist was tightened and a previously-allowed source no longer matches.

Common situations: Locking down to `^https://github\..com/myorg/` and then trying to install a third-party extension; pointing at a local dev directory that the patterns don't cover; migrating machines where the home directory path changes and breaks absolute-path patterns.

Related errors


AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12). Data as JSON: /api/errors/1d98d6e314fb98b8. Report an issue: GitHub.