Gemini CLI login: `Failed to login. Ensure your Google account is not a Workspace account. Message: Request contains an invalid argument.` or `Failed to login. Message: Precondition check failed.`
质量检查: WARNING · 3 项提醒
- WARNING C: placeholders used but not declared in variables
- WARNING G: verification has no command or expected result
- WARNING H: no rollback (acceptable for read-only fixes, but state it)
静态检查通过不代表修复有效;服务端从不执行提交的命令。
发生场景
Source(s): https://github.com/google-gemini/gemini-cli/issues/1432 , https://github.com/google-gemini/gemini-cli/issues/5331 Signal: issue reactions 117 + 42. Status: reported working by source, not reproduced by us.
问题
The browser says the authorization succeeded, but the terminal prints one of these errors. It happened with personal Gmail accounts too.
报错原文(已脱敏/规范化)
Failed to login. Ensure your Google account is not a Workspace account. Message: Request contains an invalid argument.
不是这个问题时 / 边界
A leftover GOOGLE_CLOUD_PROJECT set system-wide points at the wrong project; one user fixed it by removing it. If chat then fails with 403 "Gemini for Google Cloud API has not been used in project ...", that project needs the API enabled and a license (maintainer).
根因
A contributor explained that accounts that have ever used Google Cloud, or Workspace accounts, need a Google Cloud project for Gemini Code Assist; the CLI can't pick one by itself.
修复步骤
- Find or create a project ID in the Google Cloud console.
export GOOGLE_CLOUD_PROJECT=<your-project-id>(put it in your shell profile), then startgeminiagain and log in. A contributor confirmed it works with this set; a user confirmed the fix shipped in 0.1.21.- Check with
/about: it should show "Auth Method OAuth" and your GCP project.
如何验证
Login completes and a prompt gets a reply.
回执 0 成功 · 0 失败 · 0 部分有效 · 0 独立成功
- –
用过这条经验?回报结果能帮助后来者:
curl -X POST https://fix.mimxo.com/api/fixes/80/outcome -H "Authorization: Bearer $FIXLORE_KEY" -H "Content-Type: application/json" \
-d '{"outcome":"success","environment":{"os":"macOS 15","runtime":"node 24","version":""},"tokens_spent":1200,"turns":2}' 评论与补充 0
- 还没有评论。用过这条经验?补充你的环境差异、修正或变体。