> ## Documentation Index
> Fetch the complete documentation index at: https://docs.microsandbox.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini CLI

> Run Google's Gemini CLI against a project on your host

This guide runs the official scoped Gemini CLI package inside a disposable Node.js microVM. The project is mounted from your host, while Gemini authentication and settings live on the sandbox's root disk.

## Run Gemini CLI

**1. Start Gemini CLI**

Local-only (Writable host-directory mounts are local-only. On microsandbox cloud, use the isolated-copy alternative and omit replace-on-create.)

```sh macOS & Linux theme={null}
msb run -t --name gemini-demo --replace \
  --cpus 2 --memory 2G --root-disk 4G \
  --mount-dir ./my-project:/workspace:rw \
  --workdir /workspace \
  node:24-bookworm-slim -- sh -lc '
    apt-get update &&
    apt-get install -y --no-install-recommends ca-certificates git &&
    npm install -g @google/gemini-cli@0.52.0 &&
    exec gemini
  '
```

```powershell Windows theme={null}
msb run -t --name gemini-demo --replace `
  --cpus 2 --memory 2G --root-disk 4G `
  --mount-dir ./my-project:/workspace:rw `
  --workdir /workspace `
  node:24-bookworm-slim -- sh -lc '
    apt-get update &&
    apt-get install -y --no-install-recommends ca-certificates git &&
    npm install -g @google/gemini-cli@0.52.0 &&
    exec gemini
  '
```

Gemini CLI first asks whether you trust the workspace. Review the mounted project, then continue to authentication.

> [!TIP]
>
> For an isolated workspace, or when using microsandbox cloud, replace `--mount-dir ./my-project:/workspace:rw` with `--copy-dir ./my-project:/workspace`.

> [!WARNING]
>
> Install the scoped package exactly as shown: `@google/gemini-cli`. Do not substitute similarly named unscoped packages.

**2. Start another session**

After leaving Gemini CLI, return to the same sandbox and workspace with:

```sh Shell theme={null}
msb exec -t gemini-demo -- gemini
```

**3. Verify the installation**

Exit the TUI and run:

```sh Shell theme={null}
msb exec gemini-demo -- gemini --version
```

The pinned example prints `0.52.0`.

**4. Review or export changes**

With the default writable mount, changes are already in the host checkout. Review them inside the sandbox:

```sh Shell theme={null}
msb exec gemini-demo -- sh -lc 'cd /workspace && git status --short && git diff --stat && git diff'
```

If you chose the isolated `--copy-dir` alternative, create a patch inside the sandbox:

```sh Shell theme={null}
msb exec gemini-demo -- sh -lc 'cd /workspace && git add -N . && git diff --binary > /tmp/gemini.patch'
```

Copy the patch to the host:

```sh Shell theme={null}
msb cp gemini-demo:/tmp/gemini.patch ./gemini.patch
```

Check that it applies cleanly before applying it:

```sh Shell theme={null}
git apply --check ./gemini.patch
```

**5. Clean up**

Remove the sandbox:

```sh Shell theme={null}
msb rm -f gemini-demo
```

Removing the sandbox also removes its Gemini authentication and settings. Changes made through the default workspace mount remain in the host checkout.

## Reference

* [Gemini CLI installation](https://google-gemini.github.io/gemini-cli/docs/get-started/deployment.html)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.