LoginSignup
1
0

More than 1 year has passed since last update.

久々にfirebaseで開発に取り組んだら環境整備ではまった

Posted at

概要

firebaseで作っていた個人プロジェクトを1年ぶりくらいに再開したところデプロイで多段に失敗したのでその備忘録です。

環境としてはWindows 10のWSL1上のUbuntuで開発しています。
以前の開発時にはfirebase cliのセットアップ等も終え、deployも問題なくできていたのですが、
久しぶりに開発をしようとしたら準備運動だけで2時間ほどかかってしまいました。

エラー1

deployしようとすると、Authentication errorが発生しました。
まあ、1年ぶりだからexpireするよなぁ… と思ってfirebase login --reauthを実行すると…

$ firebase login --reauth
...
Visit this URL on this device to log in:
https://accounts.google.com/o/oauth2/auth?client_id=…(略

Waiting for authentication...

Error: An unexpected error has occurred.

おや?
ログを確認してみます。

less firebase-debug.log
[info] Visit this URL on this device to log in:
[info] https://accounts.google.com/o/oauth2/auth?client_id=...
[info]
[info] Waiting for authentication...
[debug] [2022-03-10T10:57:20.037Z] Error: spawn cmd.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:470:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
[error]
[error] Error: An unexpected error has occurred.

cmd.exeが開けないと言っています。

wsl内なのにcmd.exe?
と思ってググったところ、認証のためにWindows側のブラウザを開く必要があり、cmd.exeを呼び出しているようです。
そして、cmd.exeが存在する/mnt/c/Windows/System32にパスが通っていないので呼び出せず、エラーになっていました。
(以前はパス通ってなかったっけ?気のせい?)

というわけで.bash_profileを編集してSystem32にパスを通してあげると再認証できました。

.bash_profile
source ~/.bashrc
export PATH=$PATH:/mnt/c/Windows/System32

エラー2

認証も通ったのでついでにnodeのバージョンが古いと言われていたのでバージョンを上げました。
メージャーバージョンは10から16に…
(ちなみに、このタイミングでnvmからnに乗り換えました。というか、nvmを使っていたことを忘れてnをインストールしました…)
すると今度はdeployでビルドエラーが…

$ firebase deploy --only functions
...
Build failed: Build error details not available.Please check the logs at
https://console.cloud.google.com/...
...
Error: Functions did not deploy properly.

詳細はCLoudBuildのlogを確認しろということなので確認してみると

ERROR: error fetching storage source: generic::unknown: retry budget exhausted (3 attempts):
fetching gcs source: unpacking source from gcs: source fetch container exited with non-zero status: 2

ググってみると似たような現象はいくつかありますが戻り値が2の現象は見当たらず
(どなたか戻り値 2の意味を教えてください)

nodeのバージョンがアレかなと思ったので、Cloud functionsの12にそろえてみることに

$ sudo n 12.22.10
   installed : v12.22.10 (with npm 6.14.16)
$ node -v
v12.22.10
$ firabase deploy --only functions
...
i  functions: updating Node.js 12 function sample_func(us-central1)...
✔  functions[sample_func(us-central1)]: Successful update operation.

✔  Deploy complete!

成功しました。
無意識にlatestにしてはいけませんということですね。

まとめ

久しぶりに触れるといろいろと忘れていてだめですね。

1
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
1
0