firebase-tools: Storage emulator does not accept multiple storage targets configuration
[REQUIRED] Environment info
firebase-tools: 9.11.0
Platform: macOS 11.3.1
[REQUIRED] Test case
Follow the steps to set up multiple storage targets: https://firebase.google.com/docs/cli/targets#set-up-deploy-target-storage-database
Ensure that the firebase.json
configuration has an array of storage targets
{
// ... your other firebase configuration
"storage": [
{
"rules": "storage.rules",
"target": "default"
},
{
"rules": "our-other-target.rules",
"target": "our-other-target"
}
]
// ... rest of configuration
}
[REQUIRED] Steps to reproduce
- Configure multiple storage targets as described https://firebase.google.com/docs/cli/targets#set-up-deploy-target-storage-database
- Start emulators
- See error: Cannot start the Storage emulator without rules file specified in firebase.json: run ‘firebase init’ and set up your Storage configuration
- Remove the array of targets and declare single target as object, not array declaration
- Start emulators
- Success
[REQUIRED] Expected behavior
Configuration that is acceptable for regular deployment should be acceptable for emulator.
[REQUIRED] Actual behavior
Get error when starting the emulators with multiple storage targets
Output
$ firebase emulators:start
i emulators: Starting emulators: auth, functions, firestore, database, hosting, pubsub, storage
✔ functions: Using node@14 from host.
i firestore: Firestore Emulator logging to firestore-debug.log
i database: Database Emulator logging to database-debug.log
i pubsub: Pub/Sub Emulator logging to pubsub-debug.log
i emulators: Shutting down emulators.
i functions: Stopping Functions Emulator
i database: Stopping Database Emulator
i firestore: Stopping Firestore Emulator
i pubsub: Stopping Pub/Sub Emulator
i auth: Stopping Authentication Emulator
i hub: Stopping emulator hub
Error: Cannot start the Storage emulator without rules file specified in firebase.json: run 'firebase init' and set up your Storage configuration
Output with debug flags
[2021-05-20T06:58:23.662Z] > 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"]
[2021-05-20T06:58:23.663Z] > authorizing via signed-in user (dennis@oddbit.id)
i emulators: Starting emulators: auth, functions, firestore, database, hosting, pubsub, storage {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: auth, functions, firestore, database, hosting, pubsub, storage"}}
[2021-05-20T06:58:23.680Z] [hub] writing locator at /var/folders/d9/6zn6x8jx2_d9z478l51g275w0000gn/T/hub-cruscott---dev.json
✔ functions: Using node@14 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Using node@14 from host."}}
[2021-05-20T06:58:23.717Z] defaultcredentials: writing to file /Users/dennis/.config/firebase/dennis_oddbit_id_application_default_credentials.json
[2021-05-20T06:58:23.720Z] Setting GAC to /Users/dennis/.config/firebase/dennis_oddbit_id_application_default_credentials.json {"metadata":{"emulator":{"name":"functions"},"message":"Setting GAC to /Users/dennis/.config/firebase/dennis_oddbit_id_application_default_credentials.json"}}
[2021-05-20T06:58:23.722Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev/adminSdkConfig [none]
[2021-05-20T06:58:24.238Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev/adminSdkConfig 200
[2021-05-20T06:58:24.239Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev/adminSdkConfig {"projectId":"cruscott---dev","databaseURL":"https://cruscott---dev.firebaseio.com","storageBucket":"cruscott---dev.appspot.com","locationId":"europe-west"}
[2021-05-20T06:58:24.271Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}
[2021-05-20T06:58:24.272Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[2021-05-20T06:58:24.272Z] Starting Firestore Emulator with command {"binary":"java","args":["-Dgoogle.cloud_firestore.debug_log_level=FINE","-Duser.language=en","-jar","/Users/dennis/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.15.jar","--host","localhost","--port",8080,"--rules","/Users/dennis/development/Almo-Nature/agora/firestore.rules","--functions_emulator","localhost:5001"],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":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\",\"/Users/dennis/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.15.jar\",\"--host\",\"localhost\",\"--port\",8080,\"--rules\",\"/Users/dennis/development/Almo-Nature/agora/firestore.rules\",\"--functions_emulator\",\"localhost:5001\"],\"optionalArgs\":[\"port\",\"webchannel_port\",\"host\",\"rules\",\"functions_emulator\",\"seed_from_export\"],\"joinArgs\":false}"}}
i firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[2021-05-20T06:58:25.169Z] May 20, 2021 2:58:25 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://localhost:64196
{"metadata":{"emulator":{"name":"firestore"},"message":"May 20, 2021 2:58:25 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start\nINFO: Started WebSocket server on ws://localhost:64196\n"}}
[2021-05-20T06:58:25.225Z] API endpoint: http://localhost: {"metadata":{"emulator":{"name":"firestore"},"message":"API endpoint: http://localhost:"}}
[2021-05-20T06:58:25.226Z] 8080
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:
export FIRESTORE_EMULATOR_HOST=localhost: {"metadata":{"emulator":{"name":"firestore"},"message":"8080\nIf you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:\n\n export FIRESTORE_EMULATOR_HOST=localhost:"}}
[2021-05-20T06:58:25.226Z] 8080
Dev App Server is now running.
{"metadata":{"emulator":{"name":"firestore"},"message":"8080\n\nDev App Server is now running.\n\n"}}
[2021-05-20T06:58:25.302Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev [none]
[2021-05-20T06:58:25.718Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev 200
[2021-05-20T06:58:25.718Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/cruscott---dev {"projectId":"cruscott---dev","projectNumber":"996240691979","displayName":"Cruscott - DEV","name":"projects/cruscott---dev","resources":{"hostingSite":"cruscott---dev","realtimeDatabaseInstance":"cruscott---dev","storageBucket":"cruscott---dev.appspot.com","locationId":"europe-west"},"state":"ACTIVE"}
[2021-05-20T06:58:25.718Z] database rules config: [{"instance":"cruscott---dev","rules":"/Users/dennis/development/Almo-Nature/agora/database.rules.json"}]
[2021-05-20T06:58:25.720Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: projectId"}}
[2021-05-20T06:58:25.720Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: auto_download"}}
[2021-05-20T06:58:25.720Z] Ignoring unsupported arg: rules {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: rules"}}
[2021-05-20T06:58:25.720Z] Starting Database Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/Users/dennis/.cache/firebase/emulators/firebase-database-emulator-v4.7.2.jar","--host","localhost","--port",9000,"--functions_emulator_host","localhost","--functions_emulator_port",5001],"optionalArgs":["port","host","functions_emulator_port","functions_emulator_host"],"joinArgs":false} {"metadata":{"emulator":{"name":"database"},"message":"Starting Database Emulator with command {\"binary\":\"java\",\"args\":[\"-Duser.language=en\",\"-jar\",\"/Users/dennis/.cache/firebase/emulators/firebase-database-emulator-v4.7.2.jar\",\"--host\",\"localhost\",\"--port\",9000,\"--functions_emulator_host\",\"localhost\",\"--functions_emulator_port\",5001],\"optionalArgs\":[\"port\",\"host\",\"functions_emulator_port\",\"functions_emulator_host\"],\"joinArgs\":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"}}
[2021-05-20T06:58:27.039Z] 14:58:27.038 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
{"metadata":{"emulator":{"name":"database"},"message":"14:58:27.038 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started\n"}}
[2021-05-20T06:58:27.176Z] 14:58:27.176 [main] INFO com.firebase.server.forge.App$ - Listening at localhost:9000
{"metadata":{"emulator":{"name":"database"},"message":"14:58:27.176 [main] INFO com.firebase.server.forge.App$ - Listening at localhost:9000\n"}}
[2021-05-20T06:58:29.503Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"pubsub"},"message":"Ignoring unsupported arg: projectId"}}
[2021-05-20T06:58:29.504Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"pubsub"},"message":"Ignoring unsupported arg: auto_download"}}
[2021-05-20T06:58:29.504Z] Starting Pub/Sub Emulator with command {"binary":"/Users/dennis/.cache/firebase/emulators/pubsub-emulator-0.1.0/pubsub-emulator/bin/cloud-pubsub-emulator","args":["--host=localhost","--port=8085"],"optionalArgs":["port","host"],"joinArgs":true} {"metadata":{"emulator":{"name":"pubsub"},"message":"Starting Pub/Sub Emulator with command {\"binary\":\"/Users/dennis/.cache/firebase/emulators/pubsub-emulator-0.1.0/pubsub-emulator/bin/cloud-pubsub-emulator\",\"args\":[\"--host=localhost\",\"--port=8085\"],\"optionalArgs\":[\"port\",\"host\"],\"joinArgs\":true}"}}
i pubsub: Pub/Sub Emulator logging to pubsub-debug.log {"metadata":{"emulator":{"name":"pubsub"},"message":"Pub/Sub Emulator logging to \u001b[1mpubsub-debug.log\u001b[22m"}}
[2021-05-20T06:58:29.643Z] This is the Google Pub/Sub fake.
Implementation may be incomplete or differ from the real system.
{"metadata":{"emulator":{"name":"pubsub"},"message":"This is the Google Pub/Sub fake.\nImplementation may be incomplete or differ from the real system.\n"}}
[2021-05-20T06:58:29.667Z] May 20, 2021 2:58:29 PM com.google.cloud.pubsub.testing.v1.Main main
INFO: IAM integration is disabled. IAM policy methods and ACL checks are not supported
{"metadata":{"emulator":{"name":"pubsub"},"message":"May 20, 2021 2:58:29 PM com.google.cloud.pubsub.testing.v1.Main main\nINFO: IAM integration is disabled. IAM policy methods and ACL checks are not supported\n"}}
[2021-05-20T06:58:30.043Z] May 20, 2021 2:58:30 PM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround
INFO: Unable to apply Java 7 long hostname workaround.
{"metadata":{"emulator":{"name":"pubsub"},"message":"May 20, 2021 2:58:30 PM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround\nINFO: Unable to apply Java 7 long hostname workaround.\n"}}
[2021-05-20T06:58:30.126Z] May 20, 2021 2:58:30 PM com.google.cloud.pubsub.testing.v1.Main main
INFO: Server started, listening on 8085
{"metadata":{"emulator":{"name":"pubsub"},"message":"May 20, 2021 2:58:30 PM com.google.cloud.pubsub.testing.v1.Main main\nINFO: Server started, listening on 8085\n"}}
i emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}}
i functions: Stopping Functions Emulator {"metadata":{"emulator":{"name":"functions"},"message":"Stopping Functions Emulator"}}
i database: Stopping Database Emulator {"metadata":{"emulator":{"name":"database"},"message":"Stopping Database Emulator"}}
[2021-05-20T06:58:30.276Z] 14:58:30.276 [Thread-1] INFO com.firebase.server.forge.App$ - Attempting graceful shutdown.
{"metadata":{"emulator":{"name":"database"},"message":"14:58:30.276 [Thread-1] INFO com.firebase.server.forge.App$ - Attempting graceful shutdown.\n"}}
[2021-05-20T06:58:30.281Z] 14:58:30.280 [Thread-1] INFO com.firebase.server.forge.App$ - Graceful shutdown complete.
{"metadata":{"emulator":{"name":"database"},"message":"14:58:30.280 [Thread-1] INFO com.firebase.server.forge.App$ - Graceful shutdown complete.\n"}}
[2021-05-20T06:58:30.355Z] May 20, 2021 2:58:30 PM io.gapi.emulators.grpc.GrpcServer$3 operationComplete
INFO: Adding handler(s) to newly registered Channel.
{"metadata":{"emulator":{"name":"pubsub"},"message":"May 20, 2021 2:58:30 PM io.gapi.emulators.grpc.GrpcServer$3 operationComplete\nINFO: Adding handler(s) to newly registered Channel.\n"}}
i firestore: Stopping Firestore Emulator {"metadata":{"emulator":{"name":"firestore"},"message":"Stopping Firestore Emulator"}}
[2021-05-20T06:58:30.647Z] *** shutting down gRPC server since JVM is shutting down
{"metadata":{"emulator":{"name":"firestore"},"message":"*** shutting down gRPC server since JVM is shutting down\n"}}
[2021-05-20T06:58:30.652Z] *** server shut down
{"metadata":{"emulator":{"name":"firestore"},"message":"*** server shut down\n"}}
i pubsub: Stopping Pub/Sub Emulator {"metadata":{"emulator":{"name":"pubsub"},"message":"Stopping Pub/Sub Emulator"}}
[2021-05-20T06:58:31.024Z] *** shutting down gRPC server since JVM is shutting down
{"metadata":{"emulator":{"name":"pubsub"},"message":"*** shutting down gRPC server since JVM is shutting down\n"}}
[2021-05-20T06:58:31.028Z] *** server shut down
{"metadata":{"emulator":{"name":"pubsub"},"message":"*** server shut down\n"}}
i auth: Stopping Authentication Emulator {"metadata":{"emulator":{"name":"auth"},"message":"Stopping Authentication Emulator"}}
i hub: Stopping emulator hub {"metadata":{"emulator":{"name":"hub"},"message":"Stopping emulator hub"}}
Error: Cannot start the Storage emulator without rules file specified in firebase.json: run 'firebase init' and set up your Storage configuration
Having trouble? Try firebase [command] --help
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 21
- Comments: 32 (10 by maintainers)
Commits related to this issue
- feat(emulator): fixed not being able to specify a target when multiple configs are set in the storage emulator #3390 — committed to grgr-dkrk/firebase-tools by grgr-dkrk 2 years ago
- feat(emulator): fixed not being able to specify a target when multiple configs are set in the storage emulator #3390 — committed to grgr-dkrk/firebase-tools by grgr-dkrk 2 years ago
Any news on this issue?
same here, blocking
@samtstern @abeisgoat Can you please provide an ETA on this? It’s a blocker for deployments. Thanks.
Good catch, will get a patch out this week!
that worked, thank you for the incredibly quick response!
Hi @paymog please see https://firebase.google.com/docs/cli/targets#set-up-deploy-target-storage-database for examples on how to setup your
firebase.json
file to support different rules for different buckets.You’ll likely have to have a set up similar to the following:
Set up your targets like so:
Reopening for now until this is resolved
Ok, I’ll take a look. Thanks for the report.
Here’s my
firebase.json
:I get permission error on upload on both buckets.
I think it’s related to this issue #4346
I also get this error if I go back to my default storage rules only (previously working):
FirebaseError: Firebase Storage: An unknown error occurred, please check the error payload for server response. (storage/unknown)
Tried to follow this thread with no success https://stackoverflow.com/questions/70052479/firebase-storage-an-unknown-error-occurred-please-check-the-error-payload-for
Please, help
Hi, thanks for the fix.
Since the update, I get the following error given the same previous working code whether it is single or multiple rules configuration:
FirebaseError: Firebase Storage: User does not have permission to access '...' (storage/unauthorized) {"error":{"code":403,"message":"Permission denied. Storage Emulator has no loaded ruleset."}}
@BunFluffpaws Can’t remember where i found this fix but you can alter the storage config in firebase.json after the emulator is running to get around this issue.
E.g. https://gist.github.com/riordanpawley/cd9595cce7a3ee59e35a3b0a5ca62f0b
Thanks @DennisAlund for the very clear report!