fix(installer): bypass Gemini CLI folder-trust gate on extension install - #43
Conversation
Gemini CLI's folder-trust feature is now default-ON, and `gemini extensions install <local-dir>` trust-checks the extension source path. The installer extracts the release tarball into a temp dir that is never trusted, pipes all output to null, and the trust prompt's non-interactive default is No — so every install on a recent Gemini CLI aborted with: Installation aborted: Folder "..." is not trusted. `--consent` does not cover folder trust (it only covers the extension install consent) and no CLI flag exists for it. Use Gemini's documented headless bypass instead: GEMINI_CLI_TRUST_WORKSPACE=true, checked first in checkPathTrust. It is session-scoped, grants no persistent trust (nothing written to ~/.gemini/trustedFolders.json), and is ignored by older Gemini versions. Applied to both the uninstall and the install call — untrusted folders block uninstall too. install.sh: command-scoped env prefix; the failure hint no longer prints a recovery command referencing $src, which lives under the $tmp the RETURN trap deletes (same rule the antigravity block documents). install.ps1: sets $env:GEMINI_CLI_TRUST_WORKSPACE before the two calls and captures/restores the prior value in finally, because `iwr | iex` runs in the user's live session and the var must not leak into it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. WalkthroughThe installers now bypass Gemini workspace trust prompts during extension operations. PowerShell preserves and restores the previous environment value. Shell failure guidance uses a durable manual installation command. ChangesGemini workspace trust handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The installers now bypass the Gemini folder-trust prompt only for the installation commands and restore the PowerShell environment afterward; no actionable merge-blocking risk remains. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Problem
A Windows user running the one-liner got:
Root cause (verified against gemini-cli
mainsource —packages/cli/src/commands/extensions/install.ts,packages/core/src/utils/trust.ts,packages/cli/src/config/trustedFolders.ts):security.folderTrust.enabled ?? true), so this hits every user on a recent Gemini CLI.gemini extensions install <local-dir>trust-checks the extension source path — our just-extracted temp dir, which is never in~/.gemini/trustedFolders.json— and prompts "Do you trust the files in this folder?".Installation aborted: Folder "…" is not trusted.--consentcovers only the extension-install consent, not folder trust, and no CLI flag exists for the trust check.Fix
Run both
gemini extensions uninstallandgemini extensions installwithGEMINI_CLI_TRUST_WORKSPACE=true— Gemini's documented headless bypass for the trust gate, checked first incheckPathTrust. Untrusted folders block uninstall too, hence both commands.Properties that make this the right shape:
~/.gemini/trustedFolders.json; the only thing trusted is our own release-tarball contents for the duration of the two commands.install.sh: command-scoped prefix (VAR=… cmd). The failure hint no longer prints a recovery command referencing$src— that path lives under the$tmptheRETURNtrap deletes, the same dead-recovery-command rule the antigravity block already documents.install.ps1: sets$env:GEMINI_CLI_TRUST_WORKSPACEjust before the two calls and captures/restores the prior value infinally, becauseiwr | iexruns in the user's live PowerShell session and the var must not leak into it.CLAUDE.md: documents the gate so the env var doesn't get "cleaned up" later.Testing
bash -n/sh -npass oninstall.sh; shellcheck reports pre-existing warnings only.install.ps1parse is covered by validate.yml's repo-wide pwsh parse step (no pwsh on this machine).mainon every run, so merging fixes the one-liner immediately. Affected users just re-run it.Summary by CodeRabbit