firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.97k stars 916 forks source link

Unable to Emulate or Deploy with Firestore in Python #7397

Open n-sweep opened 6 days ago

n-sweep commented 6 days ago

[REQUIRED] Environment info

firebase-tools: 13.10.0

Platform: NixOS 24.05

[REQUIRED] Test case

# The Cloud Functions for Firebase SDK to create Cloud Functions and set up triggers.
from firebase_functions import firestore_fn, https_fn

# The Firebase Admin SDK to access Cloud Firestore.
from firebase_admin import initialize_app, firestore
import google.cloud.firestore

app = initialize_app()

@https_fn.on_request()
def addmessage(req: https_fn.Request) -> https_fn.Response:
    """Take the text parameter passed to this HTTP endpoint and insert it into
    a new document in the messages collection."""
    # Grab the text parameter.
    original = req.args.get("text")
    if original is None:
        return https_fn.Response("No text parameter provided", status=400)

    firestore_client: google.cloud.firestore.Client = firestore.client()

    # Push the new message into Cloud Firestore using the Firebase Admin SDK.
    _, doc_ref = firestore_client.collection("messages").add({"original": original})

    # Send back a message that we've successfully written the message
    return https_fn.Response(f"Message with ID {doc_ref.id} added.")

[REQUIRED] Steps to reproduce

Run firebase emulators:start or firebase deploy

[REQUIRED] Expected behavior

I did a POC with a simple function and no firestore integration at first. The emulation & deploy worked as expected. I would expect the same behavior when accessing the firestore library as well.

[REQUIRED] Actual behavior

emulation and deployment both fail with the below error:

Traceback (most recent call last):
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/firebase_admin/firestore.py", line 22, in <module>
    from google.cloud import firestore # pylint: disable=import-error,no-name-in-module
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/google/cloud/firestore/__init__.py", line 18, in <module>
    from google.cloud.firestore_v1 import gapic_version as package_version
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/google/cloud/firestore_v1/__init__.py", line 27, in <module>
    from google.cloud.firestore_v1._helpers import GeoPoint
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/google/cloud/firestore_v1/_helpers.py", line 22, in <module>
    from google.api_core import gapic_v1
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/google/api_core/gapic_v1/__init__.py", line 16, in <module>
    from google.api_core.gapic_v1 import config
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/google/api_core/gapic_v1/config.py", line 23, in <module>
    import grpc
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/grpc/__init__.py", line 22, in <module>
    from grpc import _compression
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/grpc/_compression.py", line 20, in <module>
    from grpc._cython import cygrpc
ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py", line 122, in get_functions_yaml
    functions = get_functions()
                ^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py", line 40, in get_functions
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/n/work/plato/Repos/hermes-service-python/functions/main.py", line 8, in <module>
    from firebase_admin import initialize_app, firestore
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/firebase_admin/firestore.py", line 28, in <module>
    raise ImportError('Failed to import the Cloud Firestore library for Python. Make sure '
ImportError: Failed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module.

Additional Information

the result of pip install google-cloud-firestore:

Requirement already satisfied: google-cloud-firestore in ./venv/lib/python3.11/site-packages (2.16.1)
Requirement already satisfied: google-api-core!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0 in ./venv/lib/python3.11/site-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-cloud-firestore) (2.19.1)
Requirement already satisfied: google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1 in ./venv/lib/python3.11/site-packages (from google-cloud-firestore) (2.30.0)
Requirement already satisfied: google-cloud-core<3.0.0dev,>=1.4.1 in ./venv/lib/python3.11/site-packages (from google-cloud-firestore) (2.4.1)
Requirement already satisfied: proto-plus<2.0.0dev,>=1.22.0 in ./venv/lib/python3.11/site-packages (from google-cloud-firestore) (1.24.0)
Requirement already satisfied: protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5 in ./venv/lib/python3.11/site-packages (from google-cloud-firestore) (4.25.3)
Requirement already satisfied: googleapis-common-protos<2.0.dev0,>=1.56.2 in ./venv/lib/python3.11/site-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-cloud-firestore) (1.63.2)
Requirement already satisfied: requests<3.0.0.dev0,>=2.18.0 in ./venv/lib/python3.11/site-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-cloud-firestore) (2.32.3)
Requirement already satisfied: grpcio<2.0dev,>=1.33.2 in ./venv/lib/python3.11/site-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-cloud-firestore) (1.64.1)
Requirement already satisfied: grpcio-status<2.0.dev0,>=1.33.2 in ./venv/lib/python3.11/site-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-cloud-firestore) (1.62.2)
Requirement already satisfied: cachetools<6.0,>=2.0.0 in ./venv/lib/python3.11/site-packages (from google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1->google-cloud-firestore) (5.3.3)
Requirement already satisfied: pyasn1-modules>=0.2.1 in ./venv/lib/python3.11/site-packages (from google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1->google-cloud-firestore) (0.4.0)
Requirement already satisfied: rsa<5,>=3.1.4 in ./venv/lib/python3.11/site-packages (from google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1->google-cloud-firestore) (4.9)
Requirement already satisfied: pyasn1<0.7.0,>=0.4.6 in ./venv/lib/python3.11/site-packages (from pyasn1-modules>=0.2.1->google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1->google-cloud-firestore) (0.6.0)
Requirement already satisfied: charset-normalizer<4,>=2 in ./venv/lib/python3.11/site-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-cloud-firestore) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in ./venv/lib/python3.11/site-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-cloud-firestore) (3.7)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./venv/lib/python3.11/site-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-cloud-firestore) (2.2.2)
Requirement already satisfied: certifi>=2017.4.17 in ./venv/lib/python3.11/site-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.0->google-cloud-firestore) (2024.6.2)
[debug] [2024-06-28T01:05:26.014Z] ----------------------------------------------------------------------
[debug] [2024-06-28T01:05:26.016Z] Command:       /nix/store/6g9n96qf1yx139xklnmy3v4xhjvjgsji-nodejs-20.12.2/bin/node /nix/store/0h25yhqqkya584b0dyp2sr8rry7a7yb2-firebase-tools-13.10.0/lib/node_modules/firebase-tools/lib/bin/firebase.js emulators:start --debug
[debug] [2024-06-28T01:05:26.017Z] CLI Version:   13.10.0
[debug] [2024-06-28T01:05:26.017Z] Platform:      linux
[debug] [2024-06-28T01:05:26.017Z] Node Version:  v20.12.2
[debug] [2024-06-28T01:05:26.017Z] Time:          Thu Jun 27 2024 21:05:26 GMT-0400 (Eastern Daylight Time)
[debug] [2024-06-28T01:05:26.017Z] ----------------------------------------------------------------------
[debug] 
[debug] [2024-06-28T01:05:26.082Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2024-06-28T01:05:26.083Z] > authorizing via signed-in user (noah@plato.healthcare)
[debug] [2024-06-28T01:05:26.141Z] openjdk version "19" 2022-09-20
OpenJDK Runtime Environment (build 19+-nixos)

[debug] [2024-06-28T01:05:26.142Z] OpenJDK 64-Bit Server VM (build 19+-nixos, mixed mode, sharing)

[debug] [2024-06-28T01:05:26.149Z] Parsed Java major version: 19
[info] i  emulators: Starting emulators: functions, firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions, firestore"}}
[debug] [2024-06-28T01:05:26.159Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2024-06-28T01:05:26.159Z] [firestore] Firestore Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2024-06-28T01:05:26.159Z] [firestore.websocket] websocket server for firestore only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2024-06-28T01:05:26.159Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"firestore":[{"address":"127.0.0.1","family":"IPv4","port":8080}],"firestore.websocket":[{"address":"127.0.0.1","family":"IPv4","port":9150}]},"metadata":{"message":"assigned listening specs for emulators"}}
[debug] [2024-06-28T01:05:26.163Z] [hub] writing locator at /tmp/nix-shell.uoxu2Z/nix-shell.kjSa5i/hub-test-plato-healthcare-poc.json
[debug] [2024-06-28T01:05:26.169Z] [functions] Functions Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2024-06-28T01:05:26.169Z] [eventarc] Eventarc Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2024-06-28T01:05:26.170Z] late-assigned ports for functions and eventarc emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"firestore":[{"address":"127.0.0.1","family":"IPv4","port":8080}],"firestore.websocket":[{"address":"127.0.0.1","family":"IPv4","port":9150}],"functions":[{"address":"127.0.0.1","family":"IPv4","port":5001}],"eventarc":[{"address":"127.0.0.1","family":"IPv4","port":9299}]},"metadata":{"message":"late-assigned ports for functions and eventarc emulators"}}
[warn] ⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, hosting, pubsub, storage, dataconnect {"metadata":{"emulator":{"name":"functions"},"message":"The following emulators are not running, calls to these services from the Functions emulator will affect production: \u001b[1mauth, database, hosting, pubsub, storage, dataconnect\u001b[22m"}}
[debug] [2024-06-28T01:05:26.171Z] defaultcredentials: writing to file /home/n/.config/firebase/noah_plato_healthcare_application_default_credentials.json
[debug] [2024-06-28T01:05:26.173Z] Setting GAC to /home/n/.config/firebase/noah_plato_healthcare_application_default_credentials.json {"metadata":{"emulator":{"name":"functions"},"message":"Setting GAC to /home/n/.config/firebase/noah_plato_healthcare_application_default_credentials.json"}}
[debug] [2024-06-28T01:05:26.175Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/test-plato-healthcare-poc/adminSdkConfig [none]
[debug] [2024-06-28T01:05:26.622Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/test-plato-healthcare-poc/adminSdkConfig 200
[debug] [2024-06-28T01:05:26.622Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/test-plato-healthcare-poc/adminSdkConfig {"projectId":"test-plato-healthcare-poc","storageBucket":"test-plato-healthcare-poc.appspot.com","locationId":"us-central"}
[debug] [2024-06-28T01:05:26.633Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[debug] [2024-06-28T01:05:26.633Z] Ignoring unsupported arg: single_project_mode_error {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: single_project_mode_error"}}
[debug] [2024-06-28T01:05:26.633Z] Starting Firestore Emulator with command {"binary":"java","args":["-Dgoogle.cloud_firestore.debug_log_level=FINE","-Duser.language=en","-jar","/home/n/.cache/firebase/emulators/cloud-firestore-emulator-v1.19.6.jar","--host","127.0.0.1","--port",8080,"--websocket_port",9150,"--project_id","test-plato-healthcare-poc","--rules","/home/n/work/plato/Repos/hermes-service-python/firestore.rules","--single_project_mode",true,"--functions_emulator","127.0.0.1:5001"],"optionalArgs":["port","webchannel_port","host","rules","websocket_port","functions_emulator","seed_from_export","project_id","single_project_mode"],"joinArgs":false,"shell":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\"binary\":\"java\",\"args\":[\"-Dgoogle.cloud_firestore.debug_log_level=FINE\",\"-Duser.language=en\",\"-jar\",\"/home/n/.cache/firebase/emulators/cloud-firestore-emulator-v1.19.6.jar\",\"--host\",\"127.0.0.1\",\"--port\",8080,\"--websocket_port\",9150,\"--project_id\",\"test-plato-healthcare-poc\",\"--rules\",\"/home/n/work/plato/Repos/hermes-service-python/firestore.rules\",\"--single_project_mode\",true,\"--functions_emulator\",\"127.0.0.1:5001\"],\"optionalArgs\":[\"port\",\"webchannel_port\",\"host\",\"rules\",\"websocket_port\",\"functions_emulator\",\"seed_from_export\",\"project_id\",\"single_project_mode\"],\"joinArgs\":false,\"shell\":false}"}}
[info] i  firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[debug] [2024-06-28T01:05:27.709Z] Jun 27, 2024 9:05:27 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://127.0.0.1:9150
 {"metadata":{"emulator":{"name":"firestore"},"message":"Jun 27, 2024 9:05:27 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start\nINFO: Started WebSocket server on ws://127.0.0.1:9150\n"}}
[debug] [2024-06-28T01:05:27.738Z] API endpoint: http:// {"metadata":{"emulator":{"name":"firestore"},"message":"API endpoint: http://"}}
[debug] [2024-06-28T01:05:27.739Z] 127.0.0.1:8080
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

   export FIRESTORE_EMULATOR_HOST=127.0.0.1:8080

If you are running a Firestore in Datastore Mode project, run:

   export DATASTORE_EMULATOR_HOST=127.0.0.1:8080

Note: Support for Datastore Mode is in preview. If you encounter any bugs please file at https://github.com/firebase/firebase-tools/issues.
Dev App Server is now running.

 {"metadata":{"emulator":{"name":"firestore"},"message":"127.0.0.1:8080\nIf you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:\n\n   export FIRESTORE_EMULATOR_HOST=127.0.0.1:8080\n\nIf you are running a Firestore in Datastore Mode project, run:\n\n   export DATASTORE_EMULATOR_HOST=127.0.0.1:8080\n\nNote: Support for Datastore Mode is in preview. If you encounter any bugs please file at https://github.com/firebase/firebase-tools/issues.\nDev App Server is now running.\n\n"}}
[info] ✔  firestore: Firestore Emulator UI websocket is running on 9150. {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator UI websocket is running on 9150."}}
[warn] ⚠  emulators: The Emulator UI is not starting, either because none of the running emulators have a UI component or the Emulator UI cannot determine the Project ID. Pass the --project flag to specify a project. {"metadata":{"emulator":{"name":"hub"},"message":"The Emulator UI is not starting, either because none of the running emulators have a UI component or the Emulator UI cannot determine the Project ID. Pass the --project flag to specify a project."}}
[info] i  functions: Watching "/home/n/work/plato/Repos/hermes-service-python/functions" for Cloud Functions... {"metadata":{"emulator":{"name":"functions"},"message":"Watching \"/home/n/work/plato/Repos/hermes-service-python/functions\" for Cloud Functions..."}}
[debug] [2024-06-28T01:05:27.852Z] Customer code is not Node
[debug] [2024-06-28T01:05:27.854Z] Validating python source
[debug] [2024-06-28T01:05:27.854Z] Building python source
[info] i  functions: Loaded environment variables from .env. 
[debug] [2024-06-28T01:05:27.856Z] Could not find functions.yaml. Must use http discovery
[debug] [2024-06-28T01:05:27.859Z] Running command with virtualenv: command=., args=["\"/home/n/work/plato/Repos/hermes-service-python/functions/venv/bin/activate\"","&&","python3.11","-c","\"import firebase_functions; import os; print(os.path.dirname(firebase_functions.__file__))\""]
[debug] [2024-06-28T01:05:27.888Z] stdout: /home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/firebase_functions

[debug] [2024-06-28T01:05:27.894Z] Running admin server with args: ["python3.11","\"/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py\""] and env: {"GCLOUD_PROJECT":"test-plato-healthcare-poc","K_REVISION":"1","PORT":"80","GOOGLE_CLOUD_QUOTA_PROJECT":"test-plato-healthcare-poc","FUNCTIONS_EMULATOR":"true","TZ":"UTC","FIREBASE_DEBUG_MODE":"true","FIREBASE_DEBUG_FEATURES":"{\"skipTokenVerification\":true,\"enableCors\":true}","FIREBASE_EMULATOR_HUB":"127.0.0.1:4400","FIRESTORE_EMULATOR_HOST":"127.0.0.1:8080","FIREBASE_FIRESTORE_EMULATOR_ADDRESS":"127.0.0.1:8080","CLOUD_EVENTARC_EMULATOR_HOST":"http://127.0.0.1:9299","FIREBASE_CONFIG":"{\"storageBucket\":\"test-plato-healthcare-poc.appspot.com\",\"projectId\":\"test-plato-healthcare-poc\"}","GOOGLE_APPLICATION_CREDENTIALS":"/home/n/.config/firebase/noah_plato_healthcare_application_default_credentials.json","ADMIN_PORT":"8081"} in /home/n/work/plato/Repos/hermes-service-python/functions
[debug] [2024-06-28T01:05:27.894Z] Running command with virtualenv: command=., args=["\"/home/n/work/plato/Repos/hermes-service-python/functions/venv/bin/activate\"","&&","python3.11","\"/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py\""]
[error]  * Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.

[info]  * Serving Flask app 'serving'
 * Debug mode: off

[error] WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:8081
Press CTRL+C to quit

[error] [2024-06-28 01:05:28,699] ERROR in app: Exception on /__/functions.yaml [GET]
Traceback (most recent call last):
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/firebase_admin/firestore.py", line 22, in <module>
    from google.cloud import firestore # pylint: disable=import-error,no-name-in-module
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/google/cloud/firestore/__init__.py", line 18, in <module>
    from google.cloud.firestore_v1 import gapic_version as package_version
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/google/cloud/firestore_v1/__init__.py", line 27, in <module>
    from google.cloud.firestore_v1._helpers import GeoPoint
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/google/cloud/firestore_v1/_helpers.py", line 22, in <module>
    from google.api_core import gapic_v1
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/google/api_core/gapic_v1/__init__.py", line 16, in <module>
    from google.api_core.gapic_v1 import config
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/google/api_core/gapic_v1/config.py", line 23, in <module>
    import grpc
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/grpc/__init__.py", line 22, in <module>
    from grpc import _compression
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/grpc/_compression.py", line 20, in <module>
    from grpc._cython import cygrpc
ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py", line 122, in get_functions_yaml
    functions = get_functions()
                ^^^^^^^^^^^^^^^
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py", line 40, in get_functions
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/n/work/plato/Repos/hermes-service-python/functions/main.py", line 8, in <module>
    from firebase_admin import initialize_app, firestore
  File "/home/n/work/plato/Repos/hermes-service-python/functions/venv/lib/python3.11/site-packages/firebase_admin/firestore.py", line 28, in <module>
    raise ImportError('Failed to import the Cloud Firestore library for Python. Make sure '
ImportError: Failed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module.

[error] 127.0.0.1 - - [28/Jun/2024 01:05:28] "GET /__/functions.yaml HTTP/1.1" 500 -

[debug] [2024-06-28T01:05:28.703Z] Got response code 500; body <!doctype html>
<html lang=en>
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>

[error] 127.0.0.1 - - [28/Jun/2024 01:05:28] "GET /__/quitquitquit HTTP/1.1" 200 -

[error] ⬢  functions: Failed to load function definition from source: FirebaseError: Functions codebase could not be analyzed successfully. It may have a syntax or runtime error {"metadata":{"emulator":{"name":"functions"},"message":"Failed to load function definition from source: FirebaseError: Functions codebase could not be analyzed successfully. It may have a syntax or runtime error"}}
[info] 
┌─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your app. │
└─────────────────────────────────────────────────────────────┘

┌───────────┬────────────────┐
│ Emulator  │ Host:Port      │
├───────────┼────────────────┤
│ Functions │ 127.0.0.1:5001 │
├───────────┼────────────────┤
│ Firestore │ 127.0.0.1:8080 │
└───────────┴────────────────┘
  Emulator Hub running at 127.0.0.1:4400
  Other reserved ports: 4500, 9150

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.

[debug] [2024-06-28T01:05:55.946Z] Received signal SIGINT (Ctrl-C) 1
[info]  
[info] i  emulators: Received SIGINT (Ctrl-C) for the first time. Starting a clean shutdown. 
[info] i  emulators: Please wait for a clean shutdown or send the SIGINT (Ctrl-C) signal again to stop right now. 
[info] i  emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}}
[info] i  functions: Stopping Functions Emulator {"metadata":{"emulator":{"name":"functions"},"message":"Stopping Functions Emulator"}}
[info] i  firestore: Stopping Firestore Emulator {"metadata":{"emulator":{"name":"firestore"},"message":"Stopping Firestore Emulator"}}
[debug] [2024-06-28T01:05:55.949Z] *** shutting down gRPC server since JVM is shutting down
 {"metadata":{"emulator":{"name":"firestore"},"message":"*** shutting down gRPC server since JVM is shutting down\n"}}
[debug] [2024-06-28T01:05:55.952Z] *** server shut down
 {"metadata":{"emulator":{"name":"firestore"},"message":"*** server shut down\n"}}
[info] i  eventarc: Stopping Eventarc Emulator {"metadata":{"emulator":{"name":"eventarc"},"message":"Stopping Eventarc Emulator"}}
[info] i  hub: Stopping emulator hub {"metadata":{"emulator":{"name":"hub"},"message":"Stopping emulator hub"}}
aalej commented 5 days ago

Hey @n-sweep, thanks for reaching out and for filing a detailed report. Currently, I’m unable to reproduce this issue. I created this repo using the information you provided. Could you let me know in case I’m missing anything or made a mistake in the setup? Just to note, I’m using a macOS machine to replicate this.

Also, based on the debug logs you shared, it looks like the cause of the error was ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory. I looked the error up online and found this Stack Overflow post that mentions trying to install the gcc-unwrapped package.

n-sweep commented 5 days ago

Hi @aalej, thanks for the response. I have gcc-unwrapped and stdenv.cc.cc.lib both installed. I've seen errors related to libstdc++.so.6 when working with python packages previously and installing stdenv.cc.cc.lib was the fix; this only occurs when importing the firestore library (functions alone can emulate and deploy as expected).

ETA: I have also set my LD_LIBRARY_PATH as that SO post suggests but observed no change in behavior.