JSON parsing error when running firebase init
See original GitHub issue[REQUIRED] Environment info
firebase-tools: 11.0.1
Platform: Windows
[REQUIRED] Test case
- Install firebase CLI
- Run
firebase init
[REQUIRED] Steps to reproduce
- Run
firebase init
inside a project - When asked which features to automatically set up, select
Firestore: Configure security rules and indexes files for Firestore
- Enter the default filename for Realtime Database Security Rules (database.rules.json)
[REQUIRED] Expected behavior
A json document containing database rules will be written to the project.
[REQUIRED] Actual behavior
n JSON parsing error occurs.
Logs:
? What file should be used for Realtime Database Security Rules? database.rules.json
[2022-06-05T04:05:03.019Z] >>> [apiv2][query] GET https://<MY-APP>-default-rtdb.firebaseio.com/.settings/rules.json [none]
[2022-06-05T04:05:03.773Z] <<< [apiv2][status] GET https://<MY-APP>-default-rtdb.firebaseio.com/.settings/rules.json 200
[2022-06-05T04:05:03.773Z] <<< [apiv2][body] GET https://<MY-APP>-default-rtdb.firebaseio.com/.settings/rules.json
"{\n /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */\n \"rules\": {\n \".read\": false,\n \".write\": false\n }\n}"
Error: Unable to parse JSON: SyntaxError: Unexpected token / in JSON at position 4
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top GitHub Comments
This should be resolved in
v11.1.0
(which is going out today). Sorry for not getting the fix out sooner.Duplicate #4596
Workaround I used to get around this. Grab the Realtime DB rules from your console, and create a
database.rules.json
file manually locally. Remove the comments (as mentioned above) and ensure you have a well formed json and EOF.Then run
firebase init
, and sayN
when prompted if you should overwrite the existingdatabase.storage.rules
. Rest of the init completes.