Table of Contents
久しぶりに firebase emulators:start –only functions でローカル起動すると下記のエラーが発生した。
functions のプロジェクトで node と python を2つの環境があって併用してるプロジェクトなのですがが、python だけで SDK の場所が見つかりませんのエラーになる。
エラー内容
- pyenv で設定してる python のバージョンは 3.10.13 なのだがエラーメッセージは
python3.11
となってる。よくわからない。
functions: Failed to load function definition from source: FirebaseError: Failed to find location of Firebase Functions SDK. Did you forget to run '. "/Users/ユーザー名/workspace/プロジェクト名/python/venv/bin/activate" && python3.11 -m pip install -r requirements.txt'?
解決した設定
"runtime": "python310" を追加した。
- firebase.json
{
"functions": [
{
"source": ".",
"codebase": "default",
"ignore": ["node_modules", ".git", "python", "firebase-debug.log", "firebase-debug.*.log"],
"predeploy": ["npm --prefix \"$RESOURCE_DIR\" run lint", "npm --prefix \"$RESOURCE_DIR\" run build"]
},
{
"source": "python",
"codebase": "python",
"runtime": "python310", ←★これを追加した。
"ignore": ["venv", ".git", "firebase-debug.log", "firebase-debug.*.log", ".gitignore"]
}
]
}
仮想環境の作り直し
% rm -rf venv
% python -m venv
% source venv/bin/activate
% pip install -r requirements.txt