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 ([email protected])
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
Thanks @DennisAlund for the very clear report!
Good catch, will get a patch out this week!
Any news on this issue?
@samtstern @abeisgoat Can you please provide an ETA on this? It's a blocker for deployments. Thanks.
@samtstern @abeisgoat Is there a ETA on this yet? Currently a blocker for fully using the emulator for us too. Thanks
@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
@riordanpawley Thanks, I ended up working around this by having both buckets security rules in a single file over using the wildcards, only problem though is this gets deployed to 3 env's so 6 rules for 2 buckets :D but hey.
Ive only had a quick read over the code you supplied, does it trick the emulator into only running 1 bucket or do they all still get their security rules applied?
@BunFluffpaws Can you tell more about your workaround?
@huyhn310 in your storage.rules have multiple buckets matching in the single rules file, the emulator will use it for all of them in a single file, then you can read/write to those extra buckets you create on the fly though using them in the emulator. it doesnt work for deploying them via firebase cli, but we dont manage the buckets via that just though the web console directly.
Its not nice but it worked for being able to use the emulator.
` rules_version = '2'; service firebase.storage {
//default bucket match /b/*.appspot.com/o { match /{allPaths=**} { allow read: if false; allow write: if false; } }
//next bucket match /b/your-other-bucket-s/o { match /{allPaths=**} { allow read; }
match /{accountId}/{allPaths=**} {
allow write: if request.auth != null && request.auth.uid == accountId;
}
} } `
@abeisgoat is this still being worked on? We're still waiting for fix.
Dear Jason,
Sorry for the late reply, I missed your email. I am checking on it now.
Thanks & Best Regards, HuyHN
On Wed, 6 Oct 2021 at 17:09, Jason Hu @.***> wrote:
@abeisgoat https://github.com/abeisgoat is this still being worked on? We're still waiting for fix.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-tools/issues/3390#issuecomment-935898270, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANU3OLXA7HOY32TQFBHGQLTUFQN4DANCNFSM45GFWERA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Any other workarounds?
This is blocking for me too
same here, blocking
I am blocked too. Could you please fix?
Hi all, thanks for your patience. @tohhsinpei is working on a fix to this issue, it should be included in either our upcoming release or the one following. Stay tuned for updates.
Hey there, what's the difference between using targets and bucket? I was using the configuration file as
"storage": [
...
{
"rules": "backup_storage.rules",
"bucket": "backup-bucket"
}
]
But it doesn't work because the Storage emulator requires a target set:
Error: Must supply 'target' in Storage configuration
@ggirotto A single target may identify multiple buckets. Please use the target key in your firebase.json file in accordance with the CLI docs.
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."}}
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