5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

使い道は誰かが考えてくれるでしょう。

書きたいこと

CloudShellっていろいろできるんです。
可能性は無限大。

それでは動かしてみましょう

れっつごー!

事前準備

まずは、認証情報が必要です。
どうも、認証するにはWebブラウザが必要そう?
じゃあ、他の環境で認証情報作ってコピーすればいいじゃない?

え?他の環境があるならそこで実行すれば良いじゃんって?

これが男のロマンってやつですよ。

というわけで、以下のファイルをコピー。

adzumi@cloudshell:~ (ap-tokyo-1)$ ls .gemini
oauth_creds.json  settings.json  user_id

起動してみる

まあ、コマンド一発です。

adzumi@cloudshell:~ (ap-tokyo-1)$ npx https://github.com/google-gemini/gemini-cli
Need to install the following packages:
github:google-gemini/gemini-cli
Ok to proceed? (y) y


 ███            █████████  ██████████ ██████   ██████ █████ ██████   █████ █████
░░░███         ███░░░░░███░░███░░░░░█░░██████ ██████ ░░███ ░░██████ ░░███ ░░███
  ░░░███      ███     ░░░  ░███  █ ░  ░███░█████░███  ░███  ░███░███ ░███  ░███
    ░░░███   ░███          ░██████    ░███░░███ ░███  ░███  ░███░░███░███  ░███
     ███░    ░███    █████ ░███░░█    ░███ ░░░  ░███  ░███  ░███ ░░██████  ░███
   ███░      ░░███  ░░███  ░███ ░   █ ░███      ░███  ░███  ░███  ░░█████  ░███
 ███░         ░░█████████  ██████████ █████     █████ █████ █████  ░░█████ █████
░░░            ░░░░░░░░░  ░░░░░░░░░░ ░░░░░     ░░░░░ ░░░░░ ░░░░░    ░░░░░ ░░░░░


Tips for getting started:
1. Ask questions, edit files, or run commands.
2. Be specific for the best results.
3. Create GEMINI.md files to customize your interactions with Gemini.
4. /help for more information.

必要なものは全部入ってるようです。CloudShellすごい。

> お昼ご飯のおすすめを教えてください。

✦ お昼ご飯ですね!いくつかおすすめがあります。


   * 和食: 寿司、ラーメン、うどん、そば、定食(焼き魚や唐揚げなど)
   * 洋食: パスタ、ハンバーグ、カレーライス、サンドイッチ
   * 中華: チャーハン、餃子、麻婆豆腐


  もし何か好みがあれば、それに合わせてさらに絞り込むこともできますよ!

うんうん。いい感じですね。

次はsandbox化

知ってます?CloudShellってpodman入ってるんです。

adzumi@cloudshell:~ (ap-tokyo-1)$ podman pull us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.1.1
Trying to pull us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.1.1...
Getting image source signatures
Copying blob 8378ad7fe587 done   | 
Copying blob bb7164c59a80 done   | 
Copying blob c8c8d5f01aa7 done   | 
Copying blob 63f1c9356ab2 done   | 
Copying blob 6a4104b2adf3 done   | 
Copying blob dad67da3f26b done   | 
Copying blob 8146f1bc47a5 done   | 
Copying blob e6f7b03a4107 done   | 
Copying blob 52ea2a4ae308 done   | 
Copying blob e3e79b09e697 done   | 
Copying config 150868f0b6 done   | 
Writing manifest to image destination
150868f0b639dff069c7f5f58fd2355ddcfafca097a4e66564de2420b109afef
adzumi@cloudshell:~ (ap-tokyo-1)$ podman images
REPOSITORY                                            TAG         IMAGE ID      CREATED       SIZE
us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox  0.1.1       150868f0b639  14 hours ago  781 MB

サイズも大きくないので、CloudShell上に入ります。

公式ドキュメントを見ると、sandbox実行は、手元にもgemini-cliが必要そうですが、強引にコンテナで実行します。

共有用の.gemini_podmanをローカルに作って、それをコンテナに共有します。
私がコンテナよく分かってないのもありますが、こうしないとパーミッションが書き換わってしまって。
ただ、これはこれで直接消せないファイルが出来上がってしますので、たぶん何か変えないとダメっぽいです。ご注意。

adzumi@cloudshell:~ (ap-tokyo-1)$ cp -r .gemini .gemini_podman

それでは実行します。

(2025.06.26追記) -v でボリュームマウントする際、Uオプション付けなくても大丈夫みたいなので、消せないファイル作成されるのを避けるために削除。tmpが作られなくなりますが、仕方なし。

adzumi@cloudshell:~ (ap-tokyo-1)$ podman run --rm -it -v /home/adzumi/.gemini_podman:/home/node/.gemini us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.1.1 gemini -p "お昼ご飯のおすすめを教えてください。"
Warning: Could not read directory /root: EACCES: permission denied, scandir '/root'
承知いたしました。お昼ご飯ですね。

どのようなものがお好みですか?例えば、麺類、ご飯もの、軽めのもの、がっつりしたものなど、ご希望を教えていただけますか?

もし特に希望がなければ、一般的な選択肢をいくつか提案します。検索結果によると、いくつか選択肢があるようです。

**外で食べる場合**
*   和食:お寿司、天ぷら、そば、うどん
*   洋食:パスタ、オムライス、カレーライス
*   中華:チャーハン、ラーメン

**お家で食べる場合**
*   麺類:パスタ、うどん、そうめん、冷やし中華
*   ご飯もの:カレーライス、チャーハン、親子丼、タコライス
*   パン類:サンドイッチ、フレンチトースト

もし、特定のジャンルやお店がお決まりでしたら、さらに絞ってお店を検索することも可能です。

どのようなものがよろしいでしょうか?

なんか警告出てますが、動きますね。良き良き。
警告の部分は、コンテナの中の/rootが600だからなのかもしれません。この辺はよく分からず。

終わりに

こういうのは、勢いが大事ですね☆

5
2
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
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?