created: 2024-03-24T01:41:11.582Z

firebase deploy で `Could not read source directory`

ある日、いつものようにデプロイしようとするとこんなエラーが出た。

npx firebase deploy --only functions:scrape

Error: Could not read source directory. Remove links and shortcuts and try again

原因

ビルドアーティファクトになる src にはシンボリックリンクなんてないしなんでだろうと思ったが、 --debug をつけて実行したら本当にダメになってるシンボリックリンクが見つかった。

Error: ENOENT: no such file or directory, stat '/Users/myusername/.ghq/github.com/myusername/functions/bot/default.code-workspace'

[2024-03-24T01:34:56.749Z] Error: ENOENT: no such file or directory, stat '/Users/myusername/.ghq/github.com/myusername/functions/bot/default.code-workspace'
    at Object.statSync (node:fs:1676:25)
    at /Users/myusername/.ghq/github.com/myusername/functions/node_modules/firebase-tools/node_modules/graceful-fs/polyfills.js:319:16
    at readdirRecursiveHelper (/Users/myusername/.ghq/github.com/myusername/functions/node_modules/firebase-tools/lib/fsAsync.js:14:47)

vscode 用の設定ファイルを参照させるためにつくっていたリンクファイルが参照切れしていた。エラーメッセージは正しい。

参考

先に GitHub の issue がヒットしてそちらで「ネットワークが〜」とか変な流れになってるのを読んでしまっていたが、単純なエラーなのでこちらは参考にしなくて良いと思う。エラーメッセージが正しい。

協力と裏切りの生命進化史 (光文社新書)
[ad] 協力と裏切りの生命進化史 (光文社新書)
市橋伯一 (新書)