What happened?
When running Gemini CLI using Vertex AI authentication, having standard proxy environment variables (HTTP_PROXY/HTTPS_PROXY) exported in the shell causes a fatal crash during the authentication phase.
Error Output:
TypeError: HttpsProxyAgent is not a constructor
Root Cause Analysis:
The @google-cloud/vertexai or google-auth-library relies on gaxios. When proxy env vars are present, gaxios dynamically attempts to instantiate https-proxy-agent. Due to bundling issues (likely CommonJS vs ESM export mismatch during the esbuild/webpack process of the gemini-cli bundle), the exported agent is an object rather than a constructor class.
Reproduction:
- Configure Gemini CLI to use Vertex AI auth.
export HTTPS_PROXY=http://127.0.0.1:7897
- Run any prompt in the CLI.
Workaround:
Clearing the proxy env vars and using an OS-level TUN interface works perfectly, proving the issue is strictly isolated to the proxy agent instantiation path in the bundled JS chunk.
What did you expect to happen?
The CLI should successfully instantiate the proxy agent and route the Vertex AI requests through the local proxy without crashing.
Client information
- CLI Version: 0.40.1
- Git Commit: 7a382e0
- Session ID: 7c5a9b2f-e017-4a8d-9465-ca7e748930cb
- Operating System: linux v25.9.0
- Sandbox Environment: no sandbox
- Model Version: gemini-3.1-pro-preview
- Auth Type: vertex-ai
- Memory Usage: 908.4 MB
- Terminal Name: ghostty 1.3.1-arch2.2
- Terminal Background: #121212
- Kitty Keyboard Protocol: Supported
Login information
No response
Anything else we need to know?
No response
What happened?
When running Gemini CLI using Vertex AI authentication, having standard proxy environment variables (
HTTP_PROXY/HTTPS_PROXY) exported in the shell causes a fatal crash during the authentication phase.Error Output:
TypeError: HttpsProxyAgent is not a constructorRoot Cause Analysis:
The
@google-cloud/vertexaiorgoogle-auth-libraryrelies ongaxios. When proxy env vars are present,gaxiosdynamically attempts to instantiatehttps-proxy-agent. Due to bundling issues (likely CommonJS vs ESM export mismatch during the esbuild/webpack process of thegemini-clibundle), the exported agent is an object rather than a constructor class.Reproduction:
export HTTPS_PROXY=http://127.0.0.1:7897Workaround:
Clearing the proxy env vars and using an OS-level TUN interface works perfectly, proving the issue is strictly isolated to the proxy agent instantiation path in the bundled JS chunk.
What did you expect to happen?
The CLI should successfully instantiate the proxy agent and route the Vertex AI requests through the local proxy without crashing.
Client information
Login information
No response
Anything else we need to know?
No response