google-gemini / google-gemini/gemini-cli
Sandbox does not forward GOOGLE_GENAI_API_VERSION into container
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 45
Description
### What happened?
When `GEMINI_SANDBOX=true` is set and `GOOGLE_GENAI_API_VERSION` is used alongside `GOOGLE_GEMINI_BASE_URL` to construct a Vertex-compatible API path, the sandbox fails with:
```
ModelNotFoundError: Not found (404)
```
`sandbox.ts` explicitly forwards a hardcoded list of environment variables into the Docker container (e.g., `GOOGLE_GEMINI_BASE_URL`, `GOOGLE_VERTEX_BASE_URL`, `GOOGLE_GENAI_USE_VERTEXAI`). When support for `GOOGLE_GENAI_API_VERSION` was added in `contentGenerator.ts`, the corresponding update to `sandbox.ts` was missed. The variable is available outside the sandbox but silently dropped when entering it.
Without `GOOGLE_GENAI_API_VERSION`, a `GOOGLE_GEMINI_BASE_URL` that depends on the API version segment to form a complete URL becomes invalid, and the API returns a 404.
#### Example
```sh
export GOOGLE_GEMINI_BASE_URL="https://my-gateway/vertex/"
export GOOGLE_GENAI_API_VERSION="v1beta1/projects/my-project/locations/global/publishers/google"
export GEMINI_SANDBOX=true
gemini -p "hello"
# => ModelNotFoundError: Not found (404)
```
Unsetting `GEMINI_SANDBOX` makes it work.
### What did you expect to happen?
`GOOGLE_GENAI_API_VERSION` should be forwarded into the sandbox container like the other `GOOGLE_*` environment variables, so that custom Vertex-compatible base URLs work correctly in sandbox mode.
### Client information
Client Information
Run `gemini` to enter the interactive CLI, then run the `/about` command.
```console
> /about
│ About Gemini CLI │
│ │
│ CLI Version 0.32.1 │
│ Git Commit 4d9d0b3 │
│ Model Auto (Gemini 3) │
│ Sandbox sandbox-0.32.1-0 │
│ OS linux │
│
```
### Login information
API key
### Anything else we need to know?
The environment variable was introduced in https://github.com/google-gemini/gemini-cli/pull/16177 to address [#16173](https://github.com/google-gemini/gemini-cli/issues/16173), however a small change in `sandbox.ts` is missing.
**Fix:**
Add `GOOGLE_GENAI_API_VERSION` to the forwarded env vars in `packages/cli/src/utils/sandbox.ts`, in both the Docker path ([~line 516](https://github.com/google-gemini/gemini-cli/blob/4c5e887732a24870b41d1028b1ed294493ad9033/packages/cli/src/utils/sandbox.ts#L516-L536)) and the LXC `envVarsToForward` record ([~line 957](https://github.com/google-gemini/gemini-cli/blob/4c5e887732a24870b41d1028b1ed294493ad9033/packages/cli/src/utils/sandbox.ts#L957)).
I have a fix in my fork but am unable to open a pull request due to the CLA requirement and some build issue. Anyone interested in submitting the PR is welcome to take the change from my commit:
https://github.com/google-gemini/gemini-cli/commit/d00e8b5417f998fc07a8abe5721807374186f876
---
### Workaround
Callers can use the `SANDBOX_ENV` escape hatch to forward the variable manually (e.g., `SANDBOX_ENV=GOOGLE_GENAI_API_VERSION=`). This is not ideal because it requires every caller to know about this sandbox implementation detail and shifts the burden of working around an upstream bug to downstream consumers.
Contributor guide
Assessment
This issue has not been assessed yet.