Back to Blog
BlogApril 7, 2026306

UbuntuでGemini CLIをインストールする方法:完全なステップバイステップチュートリアル

UbuntuでGemini CLIをインストールする方法:完全なステップバイステップチュートリアル

前提条件

Ubuntu に Gemini CLI をインストールする前に、以下を準備してください:

-, Ubuntu のバージョン: 20.04 LTS 以降 (22.04、24.04、および 26.04 は完全にサポートされています)。 -, 管理者権限: パッケージ管理のための Sudo 権限。 -, インターネット接続: Node.js、npm パッケージ、および認証のダウンロードに必要です。 -, Google アカウント: Gemini モデルにアクセスするための OAuth サインインに必要です。 -, 推奨ハードウェア: 対話型セッション中のスムーズなパフォーマンスのため、少なくとも 4 GB RAM と 2 CPU コア。

想定される基礎知識: ターミナルを開き、基本的な apt および bash コマンドを実行する方法を知っていること。

ステップ 1: システムパッケージの更新

まず、依存関係の競合を防ぐためにパッケージリストを更新し、既存のパッケージをアップグレードします:

sudo apt update && sudo apt upgrade -y

このステップにより、最新のセキュリティ更新とリポジトリ情報を取得できます。

ステップ 2: Node.js 20 以降のインストール

Gemini CLI には Node.js バージョン 20 以降が必要です。Ubuntu のデフォルトリポジトリには古いバージョン(例:Ubuntu 24.04 上の Node 18)が含まれていることがよくあります。

推奨方法:NodeSource リポジトリを使用

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

代替方法:nvm (Node Version Manager) を使用

より簡単なバージョン管理には:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20
nvm alias default 20

インストールを確認します:

node --version
npm --version

Node.js については v20.x.x のような出力、npm については対応するバージョンが表示されるはずです。

ステップ 3: Gemini CLI のインストール

グローバルインストール(日常使用に推奨)

npm install -g @google/gemini-cli

これにより、gemini コマンドがシステム全体で利用可能になります。

恒久的なインストールなしで簡単に試す

最初に試したい場合は:

npx @google/gemini-cli

ユーザーレベルインストール(権限の問題を回避)

グローバルインストールで権限エラーが発生する場合:

mkdir -p ~/.local/bin
npm config set prefix '~/.local'
export PATH="$HOME/.local/bin:$PATH"
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
npm install -g @google/gemini-cli

ステップ 4: インストールの確認

Gemini CLI が正しくインストールされているか確認します:

gemini --version

Gemini CLI の現在のバージョンが表示されるはずです。

ステップ 5: 起動と認証

CLI を初めて実行します:

gemini

ツールは Google でサインインするように促します。ブラウザウィンドウが自動的に開きます。OAuth フローを完了し、ターミナルに戻ります。

認証に成功すると、対話型 Gemini CLI インターフェースが読み込まれます。利用可能なコマンドを表示するには /help を使用してください。

ベストプラクティス: 起動する前にプロジェクトディレクトリに移動します:

cd ~/my-project
gemini

よくある問題とトラブルシューティング

-I gemini: command not found(gemini コマンドが見つかりません): ターミナルを再起動するか、source ~/.bashrc を実行してください。echo $PATHでPATHを確認してください。

-I npm install 中に「Permission denied」(権限が拒否されました): 上記のユーザーレベルインストール方法を使用し、sudo npmは使わないでください。

-I Node.js バージョンエラー: NodeSource のセットアップを再度実行するか、nvm を使用してバージョンを切り替えてください。node --versionで確認してください。

-I 認証に失敗します: ブラウザのポップアップブロッカーを無効にし、Cookie が有効になっていることを確認して、再試行してください。必要に応じて npm キャッシュをクリアしてください: npm cache clean --force

-I ネットワークタイムアウトやダウンロードエラー(例: ripgrep prebuilt): 安定したインターネット接続を確保してください。インストールを再試行するか、ワークアラウンドとしてnpxを使用してください。

-I ビルドツールが見つかりません: 開発用依存関係をインストールしてください:

sudo apt install -y build-essential python3

-I WSL 特有の問題: コンパイルエラーが発生した場合は、WSLではなく標準のUbuntuターミナルでコマンドを実行してください。

さらなるヘルプについては、公式GitHubリポジトリを参照してください: https://github.com/google-gemini/gemini-cli

次のステップ

  • コアコマンドを試す: CLI 内で /help/model、または /settings を入力してください。
  • プロジェクトで使用する: 自然言語のプロンプトでGeminiにコードの説明、関数のリファクタリング、新しいファイルの生成を依頼してください。
  • カスタマイズする: ~/.config/gemini-cli/ にある設定ファイルを編集して、テーマ、デフォルトモデル、拡張機能を変更してください。
  • 定期的に更新する: npm update -g @google/gemini-cli を実行して最新の改善点を入手してください。
  • ツールを統合する: Git 連携のような高度なエージェントワークフロー向けのビルトイン拡張機能や MCP サーバーで試してみてください。

これで、Ubuntu ターミナルで強力な AI コーディングアシスタントとして Gemini CLI を使用する準備が整いました。プロジェクトフォルダ内でシンプルなプロンプトから始め、徐々に複雑なエージェントタスクを構築していきましょう。

Gemini でコーディングを楽しんでください!

Share this article

Referenced Tools

Browse entries that are adjacent to the topics covered in this article.

Explore directory
Gemini CLI MCP logo

Gemini CLI MCP

Clients & Apps

Gemini CLI is an open-source terminal AI agent with MCP client support. It connects to configured MCP servers over stdio, SSE, or Streamable HTTP to extend Gemini with external tools, resources, and prompts.

GitHub Copilot Coding Agent logo

GitHub Copilot Coding Agent

MCP Servers

GitHub Copilot Coding Agent, now documented as Copilot cloud agent, is GitHub's asynchronous software development agent for researching repositories, planning changes, editing code on branches, and opening pull requests for review. It runs in a GitHub Actions-powered environment and can be started from GitHub, supported IDEs, GitHub CLI, the REST API, integrations, or the GitHub MCP Server.

Weibo Open Platform CLI logo

Weibo Open Platform CLI

MCP Servers

Weibo Open Platform CLI is the official CLI service page for using Weibo Open Platform capabilities from command-line and agent-oriented workflows. Public, parseable MCP server transport and client setup details were not available at verification time.

Agent Reach logo

Agent Reach

MCP Servers

Agent Reach is an open-source CLI and Agent Skill that installs, routes, and health-checks upstream tools for web, social, GitHub, video transcript, RSS, and search access. It is not documented as a standalone MCP server; some channels use MCP-backed upstream tools such as mcporter/Exa, xiaohongshu-mcp, and linkedin-scraper-mcp.

OpenCode MCP logo

OpenCode MCP

MCP Servers

OpenCode is an open-source AI coding agent with MCP client support. It can connect to local and remote MCP servers and expose their tools to the LLM alongside built-in OpenCode tools.

vercel eve logo

vercel eve

MCP Servers

Vercel Eve is an open-source, filesystem-first TypeScript framework for building durable AI agents on Vercel. It organizes agent capabilities as files for instructions, tools, skills, channels, schedules, subagents, and connections, including integrations with external MCP and OpenAPI tools.