google-gemini / google-gemini/gemini-cli

Bug: "HttpsProxyAgent is not a constructor" crash when using Vertex AI with HTTP_PROXY environment variables

Open
#26,533 5 comments 0 reactions 0 assignees View on GitHub
area/core effort/medium kind/bug priority/p1 status/bot-triaged
Dominant language
TypeScript
Stars
107k
Forks
14.6k
Avg merge
2d 3h
Merged PRs (30d)
45

Description

### 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:**
1. Configure Gemini CLI to use Vertex AI auth.
2. `export HTTPS_PROXY=http://127.0.0.1:7897`
3. 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.

Image

### 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:** 7a382e066
* **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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.