gemini cli install / setup

に公開

Update History

  • 2025/9/22
    • Updated the minimum required Node.js version from 18 → 20
    • Added support for installation via Homebrew (brew install gemini-cli)

What Is Gemini CLI?

Gemini CLI is the official command-line tool that lets you interact with Gemini right from your terminal.
It can execute shell commands on your behalf, automating tasks such as code generation and file operations.

https://github.com/google-gemini/gemini-cli

Installation Video (Windows)

A 54-second short video (Japanese). Recommended if you want a quick overview.

https://youtube.com/shorts/kzECK7KAX94

Prerequisites

  1. Node.js 18 or later (LTS recommended)

https://nodejs.org/en/download

What is Node.js?

Node.js is an execution environment that allows you to run JavaScript (or TypeScript) without a web browser.
Built on the same JIT-powered V8 engine used in Google Chrome, it adds a wrapper layer—a set of wrapper functions—so JavaScript can directly access OS features such as file I/O and networking.

Example of a wrapper function: fs.readFile(), which rolls the open → read → write → close system-call sequence into a single call.

https://nodejs.org/ja/about

https://typescriptbook.jp/tutorials/setup

https://jsprimer.net/use-case/nodecli/read-file/

https://nodejs.org/dist/latest-v6.x/docs/api/fs.html#fs_fs_readfile_file_options_callback

Installation

There are two ways to install it.

1. Stable release (npm)

Global install
npm install -g @google/gemini-cli
Start command
gemini

https://docs.npmjs.com/cli/v11/commands/npm-install

2. Development build (npx)

Fetches and runs the latest commit from GitHub on-the-fly.
Great for trying the newest features without worrying about manual updates, but stability may vary.

Issue I encountered (now resolved)

I once ran into a problem where Japanese input didn’t work properly.
This issue has since been fixed.

https://x.com/yugooku/status/1939290973189840918

https://x.com/yugooku/status/1940394806594945359

npx https://github.com/google-gemini/gemini-cli

https://docs.npmjs.com/cli/v11/commands/npx

Configuring Gemini CLI

  1. Configuring Gemini CLI
    Right after the first launch, Gemini CLI lets you pick a color theme.
    Gemini CLI - Color Theme Selection GIF

    Change the color theme later

    You can switch the theme at any time from the Gemini CLI prompt:

    Gemini CLI prompt
    /theme
    

    Below is a screenshot of the command in action.
    Color theme example


  1. Login
    There are three ways to sign in:

    1. Login with Google
    2. Gemini API Key (AI Studio)
    3. Vertex AI

    The quickest option is Login with Google.
    Selecting it will automatically open your browser, allowing you to sign in with your Google account in just a few clicks.


  1. Data sharing with Google
    If you do not want to allow product development/improvement data to be sent to Google, configure it as follows:

    1. In the Gemini CLI prompt, choose /privacy (type / to display and select available slash commands).
      In the Gemini CLI prompt, choose

    2. Select No.
      Select **No** in the Gemini CLI prompt

Using Gemini CLI

The experience is much like the web or mobile app. You chat with Gemini in the terminal, and Gemini can execute shell commands on your behalf.

Below is a screenshot(Japanese) where I asked it to create a new folder.
Before Gemini runs any command, you’ll be prompted to choose: Allow once, Always allow this command, or Deny.

Example: Asking Gemini to create a new folder (Japanese UI)

Beyond engineering tasks, it’s also handy for naming and organizing folders and files.

How to Exit Gemini CLI

You may need to press Ctrl + D twice to exit.

  1. In interactive mode, press Ctrl + D.
    The message “Press Ctrl+D again to exit.” appears.
  2. While that message is shown, press Ctrl + D again to quit.

Updating Gemini CLI

Update Gemini CLI
npm update -g @google/gemini-cli

Example

  1. Check the current version
  2. Update Gemini CLI
  3. Verify the updated version
Updating Gemini CLI
% gemini --version
0.1.7

% npm update -g @google/gemini-cli

added 1 package, and changed 261 packages in 5s

153 packages are looking for funding
run `npm fund` for details

% gemini --version

0.1.9

https://docs.npmjs.com/cli/v11/commands/npm-update

Can I update with `npm install -g @google/gemini-cli`?

Yes — npm install -g @google/gemini-cli will also update to the latest version.

Reinstalling the same package globally replaces it with the latest version, so it effectively works as an update. Its behavior differs slightly from npm update -g.

Command Primary use How it behaves
npm install -g @google/gemini-cli First-time install / force re-install - Fetches the latest and reinstalls
- Re-resolves dependencies
- Useful when you explicitly want to skip past versions
npm update -g @google/gemini-cli Update an existing package - Targets packages already installed
- Upgrades only what’s “updatable” without breaking the tree
- Skips when a version is pinned (e.g., @1.2.3)

Which should I use?

  • Update a single tool / cache seems suspiciousnpm install -g [<package-spec> ...]
  • Update multiple global tools at oncenpm update -g

npm install -g [<package-spec> ...] can also act as a reset if an update fails or dependencies get corrupted.

Example Updating Gemini CLI 'with npm install'
% gemini --version

0.1.9

% npm install -g @google/gemini-cli

**npm** warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead #Node.js に DOMException が標準実装されたためポリフィルが非推奨の警告です。動作には影響しません。

added 15 packages, removed 10 packages, and changed 422 packages in 8s

128 packages are looking for funding

run `npm fund` for details

% gemini --version

0.1.12

Uninstalling

If you no longer need Gemini CLI, you can uninstall it with:

Uninstalling Gemini CLI
npm uninstall -g @google/gemini-cli

https://docs.npmjs.com/cli/v11/commands/npm-uninstall

Discussion