Gemini CLI Login Error, use Login with Google

When I launch gemini and use “Login with Google”, a link opens with a “Not found” error.
At that point, going back to the IDX Terminal shows the following error:

node:events:502
      throw er; // Unhandled 'error' event
      ^

Error [ERR_STREAM_WRITE_AFTER_END]: write after end
    at ServerResponse.end (node:_http_outgoing:1047:15)
    at Server.<anonymous> (file:///home/user/.global_modules/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/code_assist/oauth2.js:182:25)
    at Server.emit (node:events:524:28)
    at parserOnIncoming (node:_http_server:1141:12)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:118:17)
Emitted 'error' event on ServerResponse instance at:
    at emitErrorNt (node:_http_outgoing:883:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
    code: 'ERR_STREAM_WRITE_AFTER_END'
}

Node.js v20.19.0

Yep, sorry. This is a known issue that’s being worked on. You unfortunately have to use the Gemini API key authentication for now (but logging in this way doesn’t include the free Gemini Code Assist license with an allowance of 60 model requests per minute and 1,000 requests per day at no charge so you have to keep an eye on your rate limits). If you want to swap over to the Gemini API key method, you’ll have to delete the selectedAuthType line in your .gemini/settings.json file (let me know if you need more info than that - I can write out the exact directions if needed). Sorry for the trouble, I know it’s not ideal.

1 Like

We now have a workaround you can use until the bug is fully patched.

Try these two step:

  1. Install the updated Gemini CLI (1.12 release) or run

npx https://github.com/google-gemini/gemini-cli

  1. Set this variable required to trigger the right behavior:

export NO_BROWSER="true"

Then run Gemini again in the terminal and it should give you an auth URL to use in an external browser that will login the CLI.

Note: You might have to delete this file first: ~/.gemini/settings.json

1 Like