In windows: error in path creating .gemini folder
What happened?
error occuring for my login attempt for gemini cli on the latest node.js version
What did you expect to happen?
Successful Login into CLI
Client information
CLI Version 0.1.18 │ │ Git Commit cd7e60e0 │ │ Model gemini-2.5-pro │ │ Sandbox no sandbox │ │ OS win32 │ │ Auth Method OAuth
Login information
Google Account
Anything else we need to know?
Code Assist login required. │
│ Attempting to open authentication page in your browser. │
│ Otherwise navigate to: │
│ │
│ https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A59212%2 │
│ Foauth2callback&access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud- │
│ platform%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email%20https%3A%2F%2Fwww.go │
│ ogleapis.com%2Fauth%2Fuserinfo.profile&state=d49435ad6d3a10588fdc4fa3e2860d3524b468f947c37 │
│ 364c2718c1289975603&response_type=code&client_id=681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib │
│ 135j.apps.googleusercontent.com │
│ │
│ │
│ ℹ Waiting for authentication... │
│ ✖ ========================================= │
│ This is an unexpected error. Please file a bug report using the /bug tool. │
│ CRITICAL: Unhandled Promise Rejection! │
│ ========================================= │
│ Reason: Error: EPERM: operation not permitted, mkdir 'C:\Users\huymi.gemini' │
│ Stack trace: │
│ Error: EPERM: operation not permitted, mkdir 'C:\Users\huymi.gemini' │
│ at async Object.mkdir (node:internal/fs/promises:858:10) │
│ at async cacheCredentials │
│ (file:///C:/Users/huymi/AppData/Roaming/npm/node_modules/@google/gemini-cli/node_modules/@ │
│ google/gemini-cli-core/dist/src/code_assist/oauth2.js:296:5) │
│ at async OAuth2Client.
I hope this helpful ,This is a Windows permissions issue. Try these solutions:
- Run as Administrator:
- Close Gemini CLI
- Right-click Command Prompt/PowerShell → "Run as administrator"
- Run gemini again
-
Manually create the directory: mkdir "C:\Users\huymi.gemini" gemini
-
Use API key instead of OAuth:
- Get key from https://aistudio.google.com/apikey
- set GEMINI_API_KEY=your-api-key-here
- gemini
The admin fix usually works immediately.
Hi! The existing reply (run as admin / mkdir / use API key) is a good starting point, but the EPERM: operation not permitted, mkdir 'C:\Users\huymi.gemini' trace suggests a few additional, deeper root causes to check. Below is an expanded troubleshooting & value‑add list you could try and (if needed) feed back to maintainers.
Key Observation (Path Formatting):
The stack shows both C:\Users\huymi.gemini (missing backslash) and C:\Users\huymi\.gemini (expected). If the first form is real (not just line wrap artifact), something may be concatenating the home path and .gemini without a path separator or an environment variable might include a trailing dot. Otherwise treat it as formatting noise—but verify.
High‑Impact Quick Fixes (Most Likely First)
- File vs Directory Collision: Check if a plain file named
C:\Users\huymi.geminiexists. If so,mkdirwill fail. Command (CMD):
dir C:\Users\huymi.gemini* /a - Manually create the correct hidden directory with proper ACL:
PowerShell:
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.gemini"
icacls "$env:USERPROFILE\.gemini" /inheritance:e - Node Version Compatibility: “Latest” Node may mean 22+, while CLI appears built/tested for Node 20 LTS. Try:
nvm install 20.16.0 && nvm use 20.16.0thengemini login - Antivirus / EDR Interference: Corporate AV (Defender, CrowdStrike, etc.) can block creation of a new hidden dot directory. Pause or add an exclusion to test.
- Environment Variable Mismatch:
echo %USERPROFILE%
echo %HOME%
IfHOMEis defined oddly (e.g. with a trailing period or missing backslash), unset it:set HOME=and retry so the CLI falls back toUSERPROFILE. - OneDrive / Network Profile: If your user profile is synced or on a network share, transient locks can raise EPERM. Pause OneDrive sync and retry.
- Alternate Config Location (Workaround): If supported (feature request if not), set something like
GEMINI_CONFIG_DIR=C:\GeminiConfigand re-run, isolating whether the user home path is the issue. - ACL Repair:
icacls C:\Users\huymi /verify
Grant modify if missing:icacls C:\Users\huymi /grant huymi:(OI)(CI)M - Minimal Node Repro (eliminates CLI logic):
node -e "const fs=require('fs');fs.mkdirSync(process.env.USERPROFILE+'\\\\.gemini',{recursive:true});console.log('OK')"
If this also fails → environment/permissions; if it succeeds → CLI path handling or race condition. - Concurrent Process / Race: A second Gemini CLI process or telemetry init could be racing
mkdir. Ensure only one instance is running for the first login attempt.
Deeper Diagnostic Steps
- Use Sysinternals Process Monitor, filter Operation=CreateFile Path contains
.gemini. Observe Result and Desired Access bits. - Capture environment variables (HOME, USERPROFILE) for the bug report.
- Check if a stale lock file or file named
.gemini(not a directory) exists. - Confirm if Node is exactly 20.x LTS (supported) vs 22+ (possibly untested).
- If on a corporate image: confirm you can manually create any hidden folder in
%USERPROFILE%(e.g..testgemini).
Likely Root Cause Categories
- Existing file (not directory) with the same target name.
- Insufficient ACL or inherited permission denial on user profile.
- AV / EDR blocking hidden directory creation or runtime instrumentation interfering.
- Path construction glitch (missing path separator due to env var).
- Unsupported Node version causing subtle fs permission regression (less likely, but worth isolating).
- Simultaneous mkdir attempts (race) without proper try/catch and fallback.
Suggested Enhancements for Maintainers
- Pre-flight check: if target exists and is not a directory, emit explicit guidance (“Found a file where a directory is expected”).
- More descriptive EPERM message: suggest verifying HOME/USERPROFILE and potential file collision.
- Support
--config-dirorGEMINI_CONFIG_DIRenv override; document it. - Wrap mkdir with
fs.mkdir(dir, { recursive: true })and gracefully handle EEXIST / EPERM with actionable instructions. - Node version check + warning if not on an officially supported LTS.
- Telemetry & login flow: defer directory creation until after a capability probe; fallback to a temp path if home write fails (with warning).
Concise Checklist (Try in Order)
dir C:\Users\huymi.gemini* /a→ remove/rename conflicting file.- Create directory manually + ensure ACL.
- Switch to Node 20 LTS and retry.
- Pause AV / OneDrive.
- Clear or unset anomalous
HOME. - Run minimal Node mkdir test.
- (If still failing) Provide ProcMon trace & env snapshot to maintainers.
If after steps 1–3 it still fails, attach:
- Output of
echo %USERPROFILE%andecho %HOME% - ProcMon event snippet for the failing CreateFile
- Result of the standalone Node mkdir test
That will help maintainers pinpoint whether this is environment-specific or a CLI path handling issue.
Let me know if you’d like a shorter version of this comment or a follow‑up feature request draft. Happy to help further.
To me it looks like it's not creating the path to the .gemini file correctly. It should be C:\Users\huymi\.gemini not C:\Users\huymi.gemini.
Hi Could you let us know if this is something you are still running into? I dont see this issue when trying to have Gemini CLI save a memory on Windows for instance.
Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.
It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.
Thank you for your contribution!