firebase-tools: Firestore Emulator exports cannot be imported on other platforms
Creating an export of windows and importing it on macOS gives an IO error.
[REQUIRED] Environment info
firebase-tools: 8.4.3
Platform: macOS and Windows
[REQUIRED] Steps to reproduce
- Create an export on windows and then import it in mac.
[REQUIRED] Expected behavior
- Should be able to run with all the imports.
[REQUIRED] Actual behavior
I get an IO error:
Exception in thread "main" com.google.cloud.datastore.core.exception.DatastoreException: /Users/akshayrajgollahalli/Documents/GitHub/accounting-ui/mock-data/firestore_export/all_namespaces\all_kinds\all_namespaces_all_kinds.export_metadata (No such file or directory)
at com.google.cloud.datastore.emulator.impl.ExportImportUtil.parseBackupFile(ExportImportUtil.java:312)
at com.google.cloud.datastore.emulator.impl.ExportImportUtil.fetchEntities(ExportImportUtil.java:60)
at com.google.cloud.datastore.emulator.firestore.CloudFirestore.main(CloudFirestore.java:89)
Caused by: java.io.FileNotFoundException: /Users/akshayrajgollahalli/Documents/GitHub/accounting-ui/mock-data/firestore_export/all_namespaces\all_kinds\all_namespaces_all_kinds.export_metadata (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:212)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:154)
at com.google.cloud.datastore.emulator.impl.ExportImportUtil.parseBackupFile(ExportImportUtil.java:308)
... 2 more
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 19
- Comments: 41 (14 by maintainers)
Commits related to this issue
- Small change to path forming for Firestore exports See discussion in #2421 — committed to firebase/firebase-tools by samtstern 4 years ago
I follow these steps to achieve import Firestore data from the windows machine on mac.
firebase emulators:start --import=./mydir --export-on-exit
all_namespaces_all_kinds.export_metadata
andoutput-0
from your previous dir to mydirfirebase emulators:start --import=./mydir --export-on-exit
and now you have imported the data šHey! I just wanted to say that this issue is still happening between Ubuntu (importing) and Windows (exporting). Iām not opening another issue as it was said in this one 2433 to consolidate here, but Iāll leave info to help with the reproduction of it:
[REQUIRED] Environment info
firebase-tools: 8.16.2
Platform: Ubuntu 20.04.1 LTS (importing) and Windows 10 (exporting)
[REQUIRED] Steps to reproduce
Create an export on windows and then import it in Ubuntu.
[REQUIRED] Expected behaviour
Should be able to run with all the imports.
[REQUIRED] Actual behaviour
I get an IO error:
Fixed in Firebase CLI v10.5.0.
This problem still happens, I started with windows and ran the repository on my mac, and got this error message. Is there any news on this?
@markgoho Thanks for bring this up. This is still on our roadmap and Iāve changed the type to bug for clarity. This is indeed a bit involved since it requires work in the Firestore Emulator (non-opensource) and also the CLI, which makes it a bit hard to prioritize. But weāre in no way pushing this āto the bottom of the pileā, nor do we have policies like fixing bugs strictly before feature requests.
It looks like the path in
firestore_export/firestore_export.overall_export_metadata
could simply always use forward slashes. Windows has no issues using an export from *nix. In our case we simply copied only that file from an export done on Linux to fix our export from Windows to work cross-platform.Agreed. This is killing me and my team. Basically Mac developers cannot write to the emulator DB for windows developers to read. Not to mention Mac developers have to manually copy and paste the latest data.
@yuchenshi can you and your team help prioritize this bug fix?
I just bumped into this issue (windows-macos) and Iām disappointed it got reported over a year ago an still is not fixed š¦
@michaelyfan the workaround we are still using is to export once on Mac/Linux and always keep the
all_namespaces_all_kinds.export_metadata
file from that original export despite any changes written to this file when exported on Windows.So we always revert the
all_namespaces_all_kinds.export_metadata
after anemulators:export
on Windows and just commit the remaining changed files.This is uncomfortable and feels hacky but still works.
Still happening. @yuchenshi Iām curious why this was tagged a feature request and if thatās what has pushed this bug to the bottom of the pile.
@floogulinc Thatās a great observation. Iāll be mostly likely going down that path when I get more time to work on it.
Iāve opened b/160784464 internally to track the work needed in the Firestore Emulator.
@yuchenshi so I did find one place we have a likely bug in the code: https://github.com/firebase/firebase-tools/blob/e10851b3b56a0473f4e3f337babcd4616e93f484/src/emulator/hubExport.ts#L57
That should use
path.join()
. But thatās actually not the source of the issue. The problem is within the Firestore export we have files like this (excuse the binary):The overall export metadata points to a path with
\
because the export was made on Windows. When the Firestore Emulator tries to read that next file (all_namespaces\all_kinds\...
) it gets theFileNotFoundException
.Iām actually not sure what the best path forward is here, do you know the best practice for handling this kind of thing? Also I have attached a
.zip
of an export with a single Firestore document made on my Windows PC that you can use for testing.data.zip
@charlesfries Would you mind providing a bit more details like the logs with
--debug
and what emulators youāre using?Also, it will be great if you can upload a sample export zipball that we can look into. Please make sure it does not contain sensitive information you donāt want to share with the public though, or you can reach out privately to Firebase Support.
Can gladly confirm that taking an export from macos and importing it on windows now work! Ā Thank you @yuchenshi et al. !! ā¤ļø š š¾
I can confir that Iām still using the workaround on Elementary OS 6 and Pop!_OS 21.04 when my collegues commit that file from their Windows 10 machines.