0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Termux (Android) への @google/gemini-cli インストール手順

Last updated at Posted at 2025-09-12

はじめに

androidのtermuxでgemini-cliをアップデートしようとしたがエラーが出てアップデートに失敗したので、gemini-cliに回避策を立ててもらいました。
gemini-cliを起動してこの記事の手順でアップデートしてもらったらすんなりいくと思います。
以下よりgemini-cliが作成した記事となります。

@google/gemini-cli は公式にはTermuxをサポートしていないため、インストールにはいくつかの回避策が必要です。
今後のアップデートでも同様の問題が発生する可能性があるため、手順を以下にまとめます。

前提条件

  • nodejs がインストールされていること。
  • ripgrep がインストールされていること。
pkg install nodejs ripgrep

インストール手順

1. インストールスクリプトを無視してインストール

まず、--ignore-scripts フラグを使用して、エラーの原因となるネイティブモジュールのコンパイルやプラットフォームチェックのスクリプトをスキップして、強制的にインストールを実行します。

node-gyp のビルドエラーを回避するために GYP_DEFINES 環境変数を設定し、念のため user-agent を偽装するフラグも追加します。

export GYP_DEFINES="android_ndk_path=''" && \
npm i -g @google/gemini-cli \
  --ignore-scripts \
  --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"

2. node-pty の手動コンパイル

次に、前の手順でスキップされた node-pty パッケージ(CLIの内部でターミナルを操作するために必要な重要パッケージ)を手動でコンパイルします。

まず、node-pty がインストールされたディレクトリに移動します。 $(npm root -g) を使うことで、環境に依存せずグローバルなnode_modulesのパスを取得できます。

cd $(npm root -g)/@google/gemini-cli/node_modules/node-pty

次に、そのディレクトリ内でコンパイルを実行します。ここでも GYP_DEFINES の設定が必要です。

export GYP_DEFINES="android_ndk_path=''" && npx node-gyp rebuild

3. インストールの確認

最後に、gemini コマンドが正しくインストールされたかバージョンを確認します。

gemini --version

バージョン番号(例: 0.4.1)が表示されれば、インストールは成功です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?