google-gemini/gemini-cli · error · Error
Could not install extension because the current workspace at
Error message
Could not install extension because the current workspace at ${this.workspaceDir} is not trusted. What it means
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.
Source
Thrown at packages/cli/src/config/extension-manager.ts:231
const isUpdate = !!previousExtensionConfig;
let newExtensionConfig: ExtensionConfig | null = null;
let localSourcePath: string | undefined;
let extension: GeminiCLIExtension | null;
try {
if (!isWorkspaceTrusted(this.settings).isTrusted) {
if (
await this.requestConsent(
`The current workspace at "${this.workspaceDir}" is not trusted. Do you want to trust this workspace to install extensions?`,
)
) {
const trustedFolders = loadTrustedFolders();
await trustedFolders.setValue(
this.workspaceDir,
TrustLevel.TRUST_FOLDER,
);
} else {
throw new Error(
`Could not install extension because the current workspace at ${this.workspaceDir} is not trusted.`,
);
}
}
const extensionsDir = ExtensionStorage.getUserExtensionsDir();
await fs.promises.mkdir(extensionsDir, { recursive: true });
if (installMetadata.type === 'local' || installMetadata.type === 'link') {
installMetadata.source = path.isAbsolute(installMetadata.source)
? installMetadata.source
: path.resolve(this.workspaceDir, installMetadata.source);
}
let tempDir: string | undefined;
if (
installMetadata.type === 'git' ||
installMetadata.type === 'github-release'View on GitHub (pinned to 5024443c72)
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.
Example fix
// before $ gemini extensions install ./ext # decline prompt // after $ gemini # accept trust prompt once, then retry install
Defensive patterns
Strategy: validation
Validate before calling
const { isTrusted } = isWorkspaceTrusted(settings);
if (!isTrusted) {
const ok = await requestConsent('Trust this workspace for extension install?');
if (!ok) throw new Error('Cannot install: workspace not trusted.');
} Type guard
function workspaceIsTrusted(settings: unknown): boolean {
return isWorkspaceTrusted(settings as MergedSettings).isTrusted;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Installation aborted: Folder "${absolutePath}" is not truste
- Invalid regex pattern in allowedExtensions setting: "${patte
- Installing extension from source "${installMetadata.source}"
- Installing extensions from remote sources is disallowed by y
- Gemini CLI is not running in a trusted directory. To proceed
AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12).
Data as JSON: /api/errors/f318fd11beaf922f.
Report an issue: GitHub.