🎤 Builder Talk: The Story Behind Lady Gaga’s Digital Experience – Register now

Issue with export/import using CLI and file paths not working properly.

14 replies
Last updated: Sep 6, 2021
I’m still (reported this a few months ago) having issues with export/import using the CLI. All imports fail with the same error
Error: Error while fetching asset from "file://./images/<image-name>.<ext>":
File does not exist at the specified endpoint
If I change that path to be absolutely defined from the root of my computer (
/Users/<username>/path/to/sanity/project/export/images/<image-name>.ext
) it works.
Seems strange that I have to go and do that for all assets (not only images, files are affected in the same way). Does this only happen to me?
Aug 30, 2021, 11:27 AM
@sanity/cli version 2.16.0
Aug 30, 2021, 11:28 AM
Have you tried importing the .tar.gz file?
Or are you unzipping, and then importing the .ndjson file?
Aug 30, 2021, 11:31 AM
unzipping, the docs say to import the
data.ndjson
file.
Aug 30, 2021, 11:32 AM
Actually, this page says to import
data.ndjson
https://www.sanity.io/docs/importing-data and this one just says to import
[FILE | FOLDER | URL]
https://www.sanity.io/docs/migrating-data
Aug 30, 2021, 11:34 AM
Sorry this has caused issues for a few months, User. My understanding of export/import is that pulling in the
.ndjson
file directly would be useful if making a batch change to content, for example, but that in most use cases one would want to pull in everything. On the Migrating Data page, there’s a line at the end of the Gotcha—“Make sure though to bring your assets along for the ride if this is the workflow you have chosen”—that needs to be much more prominent.
I’d be curious to know if User’s suggestion to import the whole tarball works for you. I’d like to make these two pages clearer and include a more complete provision of use cases.
Aug 30, 2021, 2:16 PM
Ah User, don’t sweat it! It’s just been months since I last tried so it’s not like I’ve suffered for months 😂
Hmm, that doesn’t really say anything at all that would help
😅 There’s no definition of how I’d bring along the data for the ride. Also, I haven’t even seen anywhere that you can import the tarball directly so not sure what I’ve missed here but I didn’t even know it was possible until today.
I make batch changes every now and then, but with enough time in between for me to forget how
😄 (today was one of those days), like if I change a type for example which would be relatively common I imagine.
Aug 30, 2021, 2:22 PM
Hmm, that doesn’t really say anything at all that would help  There’s no definition of how I’d bring along the data for the ride.
Sorry, prominent was the wrong word. You’re absolutely right that they need to be elaborated on, which I’ll do this week. I’ll ping you once I’m done as I’d like to invite your feedback, if that works for you.
Aug 30, 2021, 2:42 PM
Of course mate! Love to help
Aug 30, 2021, 2:43 PM
How did you go with the
.tar.gz
import? I used to run into this myself until I found out you could import the export bundle itself.
Aug 30, 2021, 4:04 PM
I didn't get a chance to try it, was pretty late over here. I already got the import working by changing all the file paths to start from the root. I've got another project that needs a migration between datasets this week as well so I'll try that then and let you know
Aug 30, 2021, 11:07 PM
Both https://www.sanity.io/docs/migrating-data and https://www.sanity.io/docs/importing-data have been updated—hopefully to clarify what is possible and improve the experience. User or anyone else, I’d welcome any feedback.
Sep 4, 2021, 6:14 PM
Thanks User, I'll check it out tomorrow
Sep 5, 2021, 12:24 AM
Awesome
user A
, that will be very helpful! Looks like it covers everything now. 🙏
Sep 6, 2021, 1:41 AM
Thanks for reviewing those, User. I appreciate that you pointed these out and hope you'll continue to do so. 🙌
Sep 6, 2021, 3:33 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
Hey all - what’s the quickest way to batch delete all documents of a certain type? It looks like the `sanity` cli tool allows...Jan 29, 2021
Best way to convert HTML to a PortableText object?Dec 3, 2020
CLI Error - zsh: command not foundJan 29, 2022
Troubleshooting GraphQL deployment with Sanity CLI loginMay 24, 2020
Troubleshooting logging in to the CLI tool using a token in a CI/CD environment.Jul 28, 2020
How to delete all docs of a specific doc type via cli?Nov 13, 2020
Changing the default view in Sanity StudioApr 15, 2020
Issue with automated build failing due to missing next.js CLIAug 24, 2020
Help needed with CLI dataset export error and duplicating datasetsMay 13, 2020
Hi everyone. I'm new to using Sanity and having a bit of an issue with local development, and wondering if someone is able...Dec 29, 2020

Related contributions

Turbo Start Sanity
- Template

The battle-tested Sanity template that powers Roboto Studio's websites

Go to Turbo Start Sanity

Schema UI - Next.js Sanity Starter
- Template

A Next.js starter template with Next.js 15, Tailwind CSS, shadcn/ui, and Sanity CMS with Live Editing. Get production-ready React components with matching Sanity schemas and queries. Build dynamic pages faster while keeping full control over customization.

Serge Ovcharenko
Go to Schema UI - Next.js Sanity Starter

The Swaddle
- Made with Sanity

A new brand identity to represent a more mature company, to signify The Swaddle’s evolution from publisher to production house, combined with an easier to navigate platform that can surface multiple content types - drawing readers through The Swaddle’s content offering.

Nightjar
Go to The Swaddle