[4] With no auth configured, a non-interactive (-p) run prints the message below and exits with code 41. This is expected before you sign in.
console
$gemini -p "hi" </dev/nullPlease set an Auth method in your ~/.gemini/settings.json or specify one of the following environment variables before running: GEMINI_API_KEY, GOOGLE_GENAI_USE_VERTEXAI, GOOGLE_GENAI_USE_GCA$echo $?41
[5] Run gemini and choose "Sign in with Google"; it opens a browser. The browser must be on a machine that can talk to the terminal running the CLI (doc).
[6] Match the error text to a cause. These are from the official troubleshooting doc (doc).
[7] If the interactive screen does not appear, look for a variable named CI or CONTINUOUS_INTEGRATION, or one starting with CI_. Any of these makes the CLI treat the environment as non-interactive. Drop it for that one command if you do not need it.
console
$env | grep '^CI'$env -u CI_TOKEN gemini
[8] If the cause is still unclear, run with --debug. In interactive mode, press F12 to open the debug console.