firebase / firebase-tools

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

Not able to download emulators on MAC #7265

Closed bbpersonal4 closed 3 weeks ago

bbpersonal4 commented 4 weeks ago

[REQUIRED] Environment info

13.10.2

firebase-tools:

Platform: macOS Sonoma v14.5 npm v10.7.0 Python v3.12.3 openjdk version "21.0.3" 2024-04-16

[REQUIRED] Test case

I installed firebase-cli using home brew. When I start up the emulators by running firebase emulators:start, it fails with the following error: Error: download failed, expected 3498269 bytes but got 3498873

[REQUIRED] Steps to reproduce

$ firebase emulators:start --only database --project my-project

[REQUIRED] Expected behavior

The emulator should start without any issues.

[REQUIRED] Actual behavior

Error: download failed, expected 3498269 bytes but got 3498873

$ firebase emulators:start --only database --project my_project --debug _(node:20512) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created) [2024-06-04T14:29:27.818Z] > 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"] [2024-06-04T14:29:27.819Z] > authorizing via signed-in user (my_user@myorg.com) [2024-06-04T14:29:27.980Z] openjdk version "21.0.3" 2024-04-16

[2024-06-04T14:29:27.980Z] OpenJDK Runtime Environment Homebrew (build 21.0.3) OpenJDK 64-Bit Server VM Homebrew (build 21.0.3, mixed mode, sharing)

[2024-06-04T14:29:27.986Z] Parsed Java major version: 21 i emulators: Starting emulators: database {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: database"}} [2024-06-04T14:29:28.730Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1 [2024-06-04T14:29:28.730Z] [database] Database Emulator only supports listening on one address (127.0.0.1). Not listening on ::1 [2024-06-04T14:29:28.730Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000},{"address":"::1","family":"IPv6","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"database":[{"address":"127.0.0.1","family":"IPv4","port":9000}]},"metadata":{"message":"assigned listening specs for emulators"}} [2024-06-04T14:29:28.733Z] [hub] writing locator at /var/folders/r5/kkvnqpwx1_12gnlvm7pmzf240000gq/T/hub-my_project.json [2024-06-04T14:29:28.738Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/my_project [none] [2024-06-04T14:29:29.093Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/my_project 200 [2024-06-04T14:29:29.094Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/my_project {"projectId":"my_project","projectNumber":"374862480084","displayName":"VB Mobile Staging","name":"projects/my_project","resources":{"hostingSite":"my_project","realtimeDatabaseInstance":"my_project","storageBucket":"my_project.appspot.com","locationId":"us-central"},"state":"ACTIVE","etag":"XXXXX"} [2024-06-04T14:29:29.094Z] database rules config: [{"instance":"my_project","rules":"/Users/my_user/cofFirebase/projects/my_project/database.rules.json"}] [2024-06-04T14:29:29.110Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: projectId"}} [2024-06-04T14:29:29.110Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: auto_download"}} [2024-06-04T14:29:29.110Z] Ignoring unsupported arg: rules {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: rules"}} [2024-06-04T14:29:29.110Z] Starting Database Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/Users/my_user/.cache/firebase/emulators/firebase-database-emulator-v4.11.2.jar","--host","127.0.0.1","--port",9000,"--single_project_mode","Warning"],"optionalArgs":["port","host","functions_emulator_port","functions_emulator_host","single_project_mode"],"joinArgs":false,"shell":false} {"metadata":{"emulator":{"name":"database"},"message":"Starting Database Emulator with command {\"binary\":\"java\",\"args\":[\"-Duser.language=en\",\"-jar\",\"/Users/my_user/.cache/firebase/emulators/firebase-database-emulator-v4.11.2.jar\",\"--host\",\"127.0.0.1\",\"--port\",9000,\"--single_project_mode\",\"Warning\"],\"optionalArgs\":[\"port\",\"host\",\"functions_emulator_port\",\"functions_emulator_host\",\"single_project_mode\"],\"joinArgs\":false,\"shell\":false}"}} i database: Database Emulator logging to database-debug.log {"metadata":{"emulator":{"name":"database"},"message":"Database Emulator logging to \u001b[1mdatabase-debug.log\u001b[22m"}} [2024-06-04T14:29:29.938Z] 10:29:29.937 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started {"metadata":{"emulator":{"name":"database"},"message":"10:29:29.937 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started\n"}} [2024-06-04T14:29:30.044Z] 10:29:30.044 [main] INFO com.firebase.server.forge.App$ - Listening at 127.0.0.1:9000 {"metadata":{"emulator":{"name":"database"},"message":"10:29:30.044 [main] INFO com.firebase.server.forge.App$ - Listening at 127.0.0.1:9000\n"}} i ui: downloading ui-v1.12.1.zip... {"metadata":{"emulator":{"name":"ui"},"message":"downloading ui-v1.12.1.zip..."}} [2024-06-04T14:29:30.127Z] >>> [apiv2][query] GET https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.12.1.zip [2024-06-04T14:29:30.256Z] <<< [apiv2][status] GET https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.12.1.zip 200 [2024-06-04T14:29:30.256Z] <<< [apiv2][body] GET https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.12.1.zip [stream] Progress: (100% of 0MB) : : : i emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}} i ui: Stopping Emulator UI {"metadata":{"emulator":{"name":"ui"},"message":"Stopping Emulator UI"}} i database: Stopping Database Emulator {"metadata":{"emulator":{"name":"database"},"message":"Stopping Database Emulator"}} [2024-06-04T14:29:30.645Z] 10:29:30.644 [Thread-0] INFO com.firebase.server.forge.App$ - Attempting graceful shutdown. {"metadata":{"emulator":{"name":"database"},"message":"10:29:30.644 [Thread-0] INFO com.firebase.server.forge.App$ - Attempting graceful shutdown.\n"}} [2024-06-04T14:29:30.649Z] 10:29:30.649 [Thread-0] INFO com.firebase.server.forge.App$ - Graceful shutdown complete. {"metadata":{"emulator":{"name":"database"},"message":"10:29:30.649 [Thread-0] INFO com.firebase.server.forge.App$ - Graceful shutdown complete.\n"}} i hub: Stopping emulator hub {"metadata":{"emulator":{"name":"hub"},"message":"Stopping emulator hub"}} i logging: Stopping Logging Emulator {"metadata":{"emulator":{"name":"logging"},"message":"Stopping Logging Emulator"}}

Error: download failed, expected 3498269 bytes but got 3498873_

google-oss-bot commented 4 weeks ago

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

aalej commented 3 weeks ago

Hey @bbpersonal4, thanks for reaching out. I’m trying to reproduce this issue, but I haven’t been able to replicate the error you’re encountering. When starting the emulators, the download completes successfully.

Looking through the logs, it seems like the failing download is the ui emulator. To isolate the issue, could you try running firebase setup:emulators:ui --debug and share the debug logs with us. The firebase setup:emulators:ui command downloads the ui emulator. Please remove any personal identifiable information(PII) before sharing the contents.

bbpersonal4 commented 3 weeks ago

Hi @aalej , that is correct. If I disable UI vi JSON, the command works fine. But, I wanted UI to work for our use-case. Here are the logs you requested: $ firebase setup:emulators:ui --debug (node:96618) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created) i ui: downloading ui-v1.12.1.zip... {"metadata":{"emulator":{"name":"ui"},"message":"downloading ui-v1.12.1.zip..."}} [2024-06-06T21:40:17.254Z] >>> [apiv2][query] GET https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.12.1.zip [2024-06-06T21:40:17.381Z] <<< [apiv2][status] GET https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.12.1.zip 200 [2024-06-06T21:40:17.381Z] <<< [apiv2][body] GET https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.12.1.zip [stream] Progress: (100% of 0MB) : : : [2024-06-06T21:40:17.427Z] <<< [apiv2][status] GET https://firebase-public.firebaseio.com/cli.json 200 [2024-06-06T21:40:17.428Z] <<< [apiv2][body] GET https://firebase-public.firebaseio.com/cli.json {"cloudBuildErrorAfter":1594252800000,"cloudBuildWarnAfter":1590019200000,"defaultNode10After":1594252800000,"minVersion":"3.0.5","node8DeploysDisabledAfter":1613390400000,"node8RuntimeDisabledAfter":1615809600000,"node8WarnAfter":1600128000000} : : : Error: download failed, expected 3498269 bytes but got 3498873

aalej commented 3 weeks ago

I haven’t had any luck with trying to reproduce this issue. It’s odd that you’re receiving a different file size than what was expected.

To unblock you from not being able to use the UI emulator, could you try following the steps bellow:

  1. Download the UI emulator from https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.12.1.zip
    • A file named ui-v1.12.1.zip should be downloaded
  2. Move the zip file into the cached emulator folder. It’s usually located in ~/.cache/firebase/emulators/
  3. Unzip the ui-v1.12.1.zip file
    • A new folder ui-v1.12.1 should be created
  4. Run firebase emulators:start

Are you able to run the emulators after doing the above steps? Also, when you manually download the file, could you check the file size? The zip file size should be 3,498,269 bytes.

bbpersonal4 commented 3 weeks ago

Hi @aalej , I was able to run the emulator after following the steps you mentioned. But, now I am getting an error that either database emulator does not have a UI component or the Emulator UI cannot determine the Project ID: $ firebase emulators:start --only database --project MY-PROJECT --debug (node:74903) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created) [2024-06-10T17:46:16.786Z] > 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"] [2024-06-10T17:46:16.787Z] > authorizing via signed-in user (MY-USER@GMAIL.COM) [2024-06-10T17:46:17.011Z] openjdk version "22" 2024-03-19

[2024-06-10T17:46:17.012Z] OpenJDK Runtime Environment Homebrew (build 22) OpenJDK 64-Bit Server VM Homebrew (build 22, mixed mode, sharing)

[2024-06-10T17:46:17.018Z] Parsed Java major version: 22 i emulators: Starting emulators: database {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: database"}} [2024-06-10T17:46:17.615Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1 [2024-06-10T17:46:17.615Z] [database] Database Emulator only supports listening on one address (127.0.0.1). Not listening on ::1 [2024-06-10T17:46:17.615Z] 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}],"database":[{"address":"127.0.0.1","family":"IPv4","port":9000}]},"metadata":{"message":"assigned listening specs for emulators"}} [2024-06-10T17:46:17.619Z] [hub] writing locator at /var/folders/r5/kkvnqpwx1_12gnlvm7pmzf240000gq/T/hub-MY-PROJECT.json [2024-06-10T17:46:17.626Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/MY-PROJECT [none] [2024-06-10T17:46:17.960Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/MY-PROJECT 200 [2024-06-10T17:46:17.961Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/MY-PROJECT {"projectId":"MY-PROJECT","projectNumber":"374862480084","displayName":"MY APP Staging","name":"projects/MY-PROJECT","resources":{"hostingSite":"MY-PROJECT","realtimeDatabaseInstance":"MY-PROJECT","storageBucket":"MY-PROJECT.appspot.com","locationId":"us-central"},"state":"ACTIVE","etag":"1_f5c75871-68df-494f-a116-da4dd96aeb5d"} [2024-06-10T17:46:17.961Z] database rules config: [{"instance":"MY-PROJECT","rules":"/Users/MY-USER/cofFirebase/projects/MY-PROJECT/database.rules.json"}] [2024-06-10T17:46:17.965Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: projectId"}} [2024-06-10T17:46:17.966Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: auto_download"}} [2024-06-10T17:46:17.966Z] Ignoring unsupported arg: rules {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: rules"}} [2024-06-10T17:46:17.966Z] Starting Database Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/Users/MY-USER/.cache/firebase/emulators/firebase-database-emulator-v4.11.2.jar","--host","127.0.0.1","--port",9000,"--single_project_mode","Warning"],"optionalArgs":["port","host","functions_emulator_port","functions_emulator_host","single_project_mode"],"joinArgs":false,"shell":false} {"metadata":{"emulator":{"name":"database"},"message":"Starting Database Emulator with command {\"binary\":\"java\",\"args\":[\"-Duser.language=en\",\"-jar\",\"/Users/MY-USER/.cache/firebase/emulators/firebase-database-emulator-v4.11.2.jar\",\"--host\",\"127.0.0.1\",\"--port\",9000,\"--single_project_mode\",\"Warning\"],\"optionalArgs\":[\"port\",\"host\",\"functions_emulator_port\",\"functions_emulator_host\",\"single_project_mode\"],\"joinArgs\":false,\"shell\":false}"}} i database: Database Emulator logging to database-debug.log {"metadata":{"emulator":{"name":"database"},"message":"Database Emulator logging to \u001b[1mdatabase-debug.log\u001b[22m"}} [2024-06-10T17:46:18.893Z] 13:46:18.892 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started {"metadata":{"emulator":{"name":"database"},"message":"13:46:18.892 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started\n"}} [2024-06-10T17:46:18.997Z] 13:46:18.997 [main] INFO com.firebase.server.forge.App$ - Listening at 127.0.0.1:9000 {"metadata":{"emulator":{"name":"database"},"message":"13:46:18.997 [main] INFO com.firebase.server.forge.App$ - Listening at 127.0.0.1:9000\n"}} ⚠ 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."}} [2024-06-10T17:46:19.193Z] >>> [apiv2][query] PUT http://127.0.0.1:9000/.settings/rules.json ns=MY-PROJECT [2024-06-10T17:46:19.193Z] >>> [apiv2][body] PUT http://127.0.0.1:9000/.settings/rules.json "{\n \"rules\": {\n \".read\": true,\n \".write\": false,\n \n \"flags\": {\n \".write\": \"auth != null && auth.token.admin == true\"\n },\n \"localization\": {\n \".write\": \"auth != null && auth.token.admin == true\"\n },\n \"action-logs\": {\n \".write\": \"auth != null && auth.token.admin == true\" \n },\n \"request-options\": {\n \".write\": \"auth != null && auth.token.admin == true\"\n },\n }\n}\n" [2024-06-10T17:46:19.408Z] 13:46:19.408 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO com.firebase.core.namespace.NamespaceActor - MY-PROJECT successfully activated FBKV (SurveyIdle(0)) wait: 80ms, init: 0ms {"metadata":{"emulator":{"name":"database"},"message":"13:46:19.408 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO com.firebase.core.namespace.NamespaceActor - MY-PROJECT successfully activated FBKV (SurveyIdle(0)) wait: 80ms, init: 0ms\n"}} [2024-06-10T17:46:19.460Z] 13:46:19.460 [NamespaceSystem-blocking-namespace-operation-dispatcher-8] INFO com.firebase.core.namespace.StateManager - Namespace MY-PROJECT status Active to Active {"metadata":{"emulator":{"name":"database"},"message":"13:46:19.460 [NamespaceSystem-blocking-namespace-operation-dispatcher-8] INFO com.firebase.core.namespace.StateManager - Namespace MY-PROJECT status Active to Active\n"}} [2024-06-10T17:46:19.475Z] <<< [apiv2][status] PUT http://127.0.0.1:9000/.settings/rules.json 200 [2024-06-10T17:46:19.475Z] <<< [apiv2][body] PUT http://127.0.0.1:9000/.settings/rules.json {"status":"ok"}

┌─────────────────────────────────────────────────────────────┐ │ ✔ All emulators ready! It is now safe to connect your app. │ └─────────────────────────────────────────────────────────────┘

┌──────────┬────────────────┐ │ Emulator │ Host:Port │ ├──────────┼────────────────┤ │ Database │ 127.0.0.1:9000 │ └──────────┴────────────────┘ Emulator Hub running at 127.0.0.1:4400 Other reserved ports: 4500

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

joehan commented 3 weeks ago

Hey @bbpersonal4, could you share your firebase.json? Based on those logs, the Emulator UI is not starting, and the code to determine whether it should is pretty straightforward (https://github.com/firebase/firebase-tools/blob/374b8f9a45112cf0b2739f34f105d6238386f89f/src/emulator/controller.ts#L143). My best guess is that you have {emulators: {"ui": {"enabled": false}} in your firebase.json

bbpersonal4 commented 3 weeks ago

Hi @joehan , good catch. I had disabled UI as I was having issues earlier. After making the suggested change in the firebase.json, it is working as expected. This issue can be closed now.

Thank you again for all the help!!!