gemini-cli - ✅(Solved) Fix Bug: "HttpsProxyAgent is not a constructor" crash when using Vertex AI with HTTP_PROXY environment variables [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#26533Fetched 2026-05-06 06:35:42
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
commented ×1cross-referenced ×1labeled ×1

Error Message

Error Output:

Root Cause

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.

Fix Action

Fix / Workaround

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.

PR fix notes

PR #26551: fix: externalize https-proxy-agent in bundle

Description (problem / solution / changelog)

Summary

Fixes #26533.

Externalizes https-proxy-agent from the main esbuild bundle so the Vertex AI / gaxios proxy path can load it through Node's runtime module resolver instead of using the bundled copy.

This avoids proxy-agent runtime failures when HTTP_PROXY / HTTPS_PROXY are set.

Details

The proxy path in gaxios lazily imports https-proxy-agent. When bundled into the CLI output, that dependency can hit bundling/runtime interop problems. Keeping it external preserves the package's normal runtime export shape.

This PR also adds https-proxy-agent to the root runtime dependencies so the published CLI package can resolve the externalized import after installation.

Related Issues

Fixes #26533

How to Validate

  • npx prettier --check esbuild.config.js package.json package-lock.json
  • npm run bundle
  • npm pack
  • Installed the packed tarball into a clean temp project
  • Verified require.resolve('https-proxy-agent') succeeds from the clean installed package
  • npm run preflight
  • git diff --check

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any) — no breaking changes
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

Changed files

  • esbuild.config.js (modified, +1/-0)
  • package-lock.json (modified, +1/-0)
  • package.json (modified, +1/-0)
RAW_BUFFERClick to expand / collapse

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.

<img width="2441" height="942" alt="Image" src="https://github.com/user-attachments/assets/b081ac24-de64-44dd-9721-e69f4ef35d3c" />

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

extent analysis

TL;DR

Clearing the HTTP_PROXY and HTTPS_PROXY environment variables allows the Gemini CLI to authenticate with Vertex AI without crashing.

Guidance

  • Verify that the issue is resolved by clearing the proxy environment variables and then running the Gemini CLI with Vertex AI authentication.
  • Investigate the bundling process of the gemini-cli bundle to identify and fix the CommonJS vs ESM export mismatch issue.
  • Consider using an OS-level TUN interface as a temporary workaround to route requests through a local proxy.
  • Check the @google-cloud/vertexai and google-auth-library documentation for any known issues or updates related to proxy authentication.

Example

No code snippet is provided as the issue is related to the bundling process and environment variables.

Notes

The root cause of the issue is likely due to the bundling process, but the exact solution may require further investigation and updates to the gemini-cli bundle.

Recommendation

Apply the workaround of clearing the HTTP_PROXY and HTTPS_PROXY environment variables, as it has been proven to resolve the issue in the short term.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING